eos icon indicating copy to clipboard operation
eos copied to clipboard

When calling the action of my own contract,terminal has an error!

Open dumbFeng opened this issue 8 years ago • 2 comments

Compiling and deploying are normal,but when I called the action ,there is an error:

./cleos push action leslie add '["rf","RF",13211111111]' -p leslie
> Error 3050002: Invalid Action Arguments
> Ensure that your arguments follow the contract abi!
> You can check the contract's abi by using 'cleos get code' command.
> Error Details:
> '["rf","RF","13211111111"]' is invalid args for action 'add' code 'leslie'. expected '[{"name":"account","type":"account_name"},{"name":"name","type":"string"},{"name":"phone","type":"uint64"}]'
> itr != structs.end(): Unknown struct account_name

The action code is:

    void add(const account_name account, const string& name, uint64_t phone) {

        require_auth(account);

        address_index addresses(_self, _self);

        auto itr = addresses.find(account);
        eosio_assert(itr == addresses.end(), "Address for account already exists");

        addresses.emplace(account, [&](auto& address){
            address.account = account;
            address.name = name;
            address.phone = phone;
        });
    }

Thank you for reading!

dumbFeng avatar May 29 '18 06:05 dumbFeng

edit your abi file and change account_name to name, rebuild wast file et reexecute your action

maxb14 avatar May 29 '18 11:05 maxb14

Yeah, I think it's very likely that you don't have typedef for account_name in your abi, please follow @maxb14 recommendation and it should be fine

andriantolie avatar Jul 20 '18 08:07 andriantolie