Skip to main content
2 of 5
deleted 932 characters in body

Make a transfer from contract code in behalf of user

Installed: eosio: 1.7.3; eosio.cdt: 1.6.1

Implemented and locally deployed: sample market contract and eosio.token contract. When I try to make an inline transfer from market contract:

transfer_tokens(buyer, seller, asset(tokensToTransfer, symbol("ABC", 4)), "transfer tokens to seller");
void market::transfer_tokens(name from, name to, asset quantity, string memo)
{
    token::transfer_action transfer("eosio.token"_n, {from, "active"_n});
    transfer.send(from, to, quantity, memo);
}

I get the following error: assertion failure with message: unable to find key

Account configuration:

buyer

"account_name": "buyer",
  "permissions": [{
      "perm_name": "active",
      "parent": "owner",
      "required_auth": {
        "threshold": 1,
        "keys": [{
            "key": "EOS8WqoYNnZZFHsgAhHRbcbVJWS7gpxJhPZ18pyVWDZ2nDMpgbdC8",
            "weight": 1
          }
        ],
        "accounts": [{
            "permission": {
              "actor": "market",
              "permission": "eosio.code"
            },
            "weight": 1
          }
        ],
        "waits": []
      }
    }

market

"account_name": "market",
  "permissions": [{
      "perm_name": "active",
      "parent": "owner",
      "required_auth": {
        "threshold": 1,
        "keys": [{
            "key": "EOS6hG7kidcSWFtq9asuyUK2HqpykoTeQiej5gdEkpmvphZnkZDA3",
            "weight": 1
          }
        ],
        "accounts": [{
            "permission": {
              "actor": "market",
              "permission": "eosio.code"
            },
            "weight": 1
          }
        ],
        "waits": []
      }
    }

eosio.token

"account_name": "eosio.token",
  "permissions": [{
      "perm_name": "active",
      "parent": "owner",
      "required_auth": {
        "threshold": 1,
        "keys": [{
            "key": "EOS5qurrzztw3rJMLfbXSC8K2GQUf2U43Ms11Rp3LNCYZscwFZznn",
            "weight": 1
          }
        ],
        "accounts": [{
            "permission": {
              "actor": "eosio.token",
              "permission": "eosio.code"
            },
            "weight": 1
          }
        ],
        "waits": []
      }
    }