I'm learning to make my own contract and I'm having a hard time getting LNX that is transferred to the contract to be recorded ad a balance.

#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>

using namespace std;
using namespace eosio;

class [[eosio::contract]] elevated : public eosio::contract {

    const symbol _symbol;
    elevated(name receiver, name code, datastream<const char*> ds ):contract(receiver, code, ds),_symbol("LNX", 8) {}

    void login (name username) {
      users_table _users(get_self(), get_first_receiver().value);
      auto iterator = _users.find(username.value);

      if (iterator == _users.end()) {
        iterator = _users.emplace(username, [&](auto& new_user) {
          new_user.username = username;


    void deposit(name from, name to, eosio::asset quantity, std::string memo) {
      if (from == get_self() || to != get_self())
        print("This doesnt print");
      balance_table _balance(get_self(), from.value);
      auto iterator = _balance.find(_symbol.raw());

      if (iterator == _balance.end())
        iterator = _balance.emplace(get_self(), [&](auto& new_balance) {
          new_balance.funds = quantity;
      else _balance.modify(iterator, get_self(), [&](auto& new_balance) {
        new_balance.funds += quantity;


    struct [[eosio::table]] user_info {
      name username;
      auto primary_key() const {
        return username.value;
    typedef eosio::multi_index<name("users"), user_info> users_table;

    struct [[eosio::table]] balance {
      eosio::asset funds;
      uint64_t primary_key() const { 
        return funds.symbol.raw();
    typedef eosio::multi_index<name("balance"), balance> balance_table;


I'm calling the contract with cleos -u https://testnet.lynx.eosdetroit.io:443 transfer account00001 account00002 '1.00000000 LNX' 'Test Balance' -p account00001@active


I see two problems:

Problem 1: The cleos transfer function is only for transferring EOS, if you want to transfer a different token you have to do it like this: cleos push action CONTRACT_NAME transfer '{"from":"account00001","to":"account00002","quantity":"1.00000000 LNX","memo":"Test Balance" -p account00001

The second problem is account names in EOS can not have a 0 in them, so the accounts you want to send money from and to can't succeed with the account names you specified. Allowed names are lower case, 12 characters or less, and may contain numbers 1-5 and a period (.)

| improve this answer | |

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.