0
 async function openAccount (tokenCreator ) {
 try{
const result = await api.transact({
    actions: [{
      account: tokenCreator,      //'eosio.token',
      name: 'open',                //'transfer',
      authorization: [{
        actor: tokenCreator, //'useraaaaaaaa',
        permission: 'active',
      }],
      data: {
        owner: newaccount,
        symbol: 'DAN',  
        ram_payer: tokenCreator,            //must be same as issuer
      },
    }]
  }, {
    broadcast: true,
    blocksBehind: 3,
    expireSeconds: 30,
  });
  console.dir(result);
}catch (e) {
console.log('\nCaught exception: ' + e);
if (e instanceof RpcError)
  console.log(JSON.stringify(e.json, null, 2));}};

The above code is throwing error: Caught exception: Error: Invalid symbol

  1. What is the valid symbol format? Already created token symbol (e.g. EOS) or some new token to be created. I tried both but it throws the same error. I even tried '1.0000 DAN'.

  2. What to write in owner field of data, already existing account or a new account to be created?

Open : Allows ram_payer to create an account owner with zero balance for token symbol at the expense of ram_payer.

  1. At the expense of ram_payer means the EOS tokens of the ram_payer will be staked, right?

Please, guide me I'm a newbie. Thanks in advance.

0

The reason you're getting this error is because the open action expects the symbol to be of type symbol, not symbol_code. EOS has 2 different structs that are used to represent token symbols:

  • symbol_code - this is basically just a string representing the symbol code (i.e. - EOS, DAN).
  • symbol - this class is defined by a symbol_code, and an integer that represents the token precision. You can represent an instance of this class using a string like in this format: $PRECISION,$SYMBOL_CODE.

So, let's say DAN is a token with 4 decimals, you'll need to pass in 4,DAN rather than just DAN.

| improve this answer | |
  • Thank you. It works. – AditiB Jan 3 at 9:41
0

Solution by yuval-weiss solves my error. I'll answer the other questions too so that they might help others.

    1. $PRECISION,$SYMBOL_CODE i.e. 4,DAN
    1. Already existing account
    1. Yes. EOS tokens of the ram_payer will be consumed for ram and not staked.
| 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.