I am developing an EOS dapp game
When the user acts on the contract after Scatter authentication, the logic is to deposit the bet amount from the user to the contract account.
But I get an eosio.code error. Currently being tested on junglenet This is a situation where we connect 'cleos' command to junglenet and grant eosio.code permission to the contract.
We attach various test cases. I am wondering what is wrong with the code.
first permission_level username, active
void fireballgame::bet(uint64_t game_id, name username, asset betting_amount) {
require_auth(username);
action(
permission_level(username, "active"_n),
"eosio.token"_n,
"transfer"_n,
std::make_tuple(username, _self, betting_amount, std::string(""))
).send();
}
{ "code": 500, "message": "Internal Service Error", "error": { "code": 3090003, "name": "unsatisfied_authorization", "what": "Provided keys, permissions, and delays do not satisfy declared authorizations", "details": [ { "message": "transaction declares authority '{\"actor\":\"onecenttest1\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms, provided permissions [{\"actor\":\"centcontract\",\"permission\":\"eosio.code\"}], provided keys [], and a delay max limit of 3888000000 ms", "file": "authorization_manager.cpp", "line_number": 524, "method": "check_authorization" }, { "message": "pending console output: ", "file": "apply_context.cpp", "line_number": 113, "method": "exec_one" } ] } }
second permission_level _self, eosio.code (contrect name centcontract)
void fireballgame::bet(uint64_t game_id, name username, asset betting_amount) {
require_auth(username);
action(
permission_level(_self, "eosio.code"_n),
"eosio.token"_n,
"transfer"_n,
std::make_tuple(username, _self, betting_amount, std::string(""))
).send();
}
{ "code": 500, "message": "Internal Service Error", "error": { "code": 3050000, "name": "action_validate_exception", "what": "Action validate exception", "details": [ { "message": "inline action's authorizations include a non-existent permission: {\"actor\":\"centcontract\",\"permission\":\"eosio.code\"}", "file": "apply_context.cpp", "line_number": 278, "method": "execute_inline" }, { "message": "pending console output: ", "file": "apply_context.cpp", "line_number": 113, "method": "exec_one" } ] }
I have obtained 'eosio.code' permission via the cleos command
So I tried the required permission of _self as active
void fireballgame::bet(uint64_t game_id, name username, asset betting_amount) {
require_auth(username);
action(
permission_level(_self, "active"_n),
"eosio.token"_n,
"transfer"_n,
std::make_tuple(username, _self, betting_amount, std::string(""))
).send();
}
{ "code": 500, "message": "Internal Service Error", "error": { "code": 3090004, "name": "missing_auth_exception", "what": "Missing required authority", "details": [ { "message": "missing authority of onecenttest1", "file": "apply_context.cpp", "line_number": 201, "method": "require_authorization" }, { "message": "pending console output: ", "file": "apply_context.cpp", "line_number": 113, "method": "exec_one" } ] } }
..?? The user (onecenttest1) is not authorized again
I wonder if I am using the wrong contract
please answer about my question