#Intermittent Contract Invocation Failure: Unauthorized function call for address” Error

5 messages · Page 1 of 1 (latest)

tranquil rover
#

Hello everyone,

I’ve written a simple contract that calls the approve function on a SAC client.

I’m invoking this contract using the .NET SDK (though I believe the SDK is not the issue). With the exact same arguments, the invocation sometimes fails and sometimes succeeds.

At the start of the function, I have this:
address.require_auth();
and later:
client.approve(...)
and later, some small instance storage writes:
e.storage().instance().set(...

Here are the transaction hashes on testnet for reference:
Failed transaction hash: bc60124baae241537e4a21e8105bc662fb86c95e3a7bf52ca868fde55f479f4b
Successful transaction hash: e3d8c458f1514e3b5a01c8d59907b8af3e2e5dea5850d5e9e4b87348edee1bbe

One of the diagnostic events for the failed transaction indicates an Unauthorized function call for address error for the approve function. However, the address did sign the transaction, so I’m unsure if the error message is misleading or if I’m missing something.

Any suggestions on how to diagnose and resolve this issue would be greatly appreciated.

Thank you for your help!

magic prism
#

hey, check dm

oak goblet
#

Watch out for scammers in your dm.

honest gull
#

it's hard to tell for sure without seeing the contract code, but there is a suspicious field in your signature payload:

{
1 item
"u32":
4031195,
},

that's the parameter of approve function that determines for how long the approval is going to be valid. do you happen to generate this value based on the ledger sequence? if so, that's a bad idea, as it would require a different signature every ledger. the value should be generated off-chain instead and passed to the contract call

tranquil rover