Specific example from a contract:
...
void hi(name user){
// verification here, require_auth(user)?
print(user);
}
...
I've tried require_auth(user)
but that seems to always fail unless the user itself is the contract's creator.
Thanks!
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communitySpecific example from a contract:
...
void hi(name user){
// verification here, require_auth(user)?
print(user);
}
...
I've tried require_auth(user)
but that seems to always fail unless the user itself is the contract's creator.
Thanks!
require_auth(user)
will ensure the sender of the transaction has the correct permission, which is what you're intending. Perhaps the way you're calling the action is incorrect?
When using cleos push action ...
the -p
(or --permission
) option allows you to specify the account authority you want to use.
OP here, lost the account I made this post with. I figured it out! Log:
$ cleos push action CONTRACT_NAME hi '[useruseruser]' -p CONTRACT_NAME
Error 3090004: Missing required authority
Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.
Error Details:
missing authority of useruseruser
pending console output:
By doing cleos push action CONTRACT_NAME hi '[useruseruser]' -p useruseruser
instead, it returns Hello, useruseruser
. Since I have authority over the useruseruser account the action worked.
Thanks for the advice on where to look!