1

I ran through the hello world tutorial.

First time I ran through using v1.6 of nodeos and it worked as advertised.

Upgraded to v1.7 of nodeos and the require_auth(user) did not restrict user from saying hi to other users as it did the first time I ran through it.

More confusing to me, both Alice and Bob have the same public keys

root@eosnode5:/opt/eos/contracts/hello# cleos get account alice
created: 2019-03-27T01:49:46.500
permissions: 
     owner     1:    1 EOS7WX9jdhYLR5FPKFpfZMz6fFzzVewL4iEMtWHWDbUtY3JCbY4az
        active     1:    1 EOS7WX9jdhYLR5FPKFpfZMz6fFzzVewL4iEMtWHWDbUtY3JCbY4az

permissions: 
     owner     1:    1 EOS7WX9jdhYLR5FPKFpfZMz6fFzzVewL4iEMtWHWDbUtY3JCbY4az
        active     1:    1 EOS7WX9jdhYLR5FPKFpfZMz6fFzzVewL4iEMtWHWDbUtY3JCbY4az


cleos push action hello hi '["bob"]' -p alice@owner
executed transaction:   {"user":"bob"}
Hello, bob

cleos push action hello hi '["alice"]' -p bob@owner
executed transaction: 
hello <= hello::hi                    {"user":"alice"}
Hello, alice

Clearly not the desired effect.

here's the code,

class [[eosio::contract]] hello : public contract {
  public:
      using contract::contract;

      [[eosio::action]]
      void hi( name user ) {
           require_auth( user );
           print( "Hello, ", user);
      }
};

Any idea why the accounts require_auth() isn't working? Is it because the have the same public keys?

Also, anyone point me to an in depth explanation of the account structure. That would be helpful.

Thanks!!!

  • It is not because of same key pairs, we can have as many accounts as we can using same keys, And they behave differently. For that you can explore scatter desktop and import the keys which you used for creating multiple accounts. https://get-scatter.com/ you can use this link. Now coming to your problem of require_auth(user) it will work for every account. Try to use require_auth(_self) and don't pass any argument, So this case the account who push the contract will work and for any other account it won't. – Nirdesh Kumar Choudhary Mar 27 '19 at 8:21
  • I change require_auth( _self ) and I can still push alice as -p bob@active. – sparcusa Mar 28 '19 at 20:10
1

Confirm Alice & Bob are using different keys to access their account, can do this with

cleos get account alice
cleos get account bob

Once confirmed, check what keys you have available to cleos when it attempts these commands, can list keys with cleos wallet list keys I believe.

If Alice & Bob's keys are in there, cleos might be mixing and matching, remove bobs keys and then run your test again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.