1

I am trying to create and account from another account, both on JungleNet. I am using junglenet rpc. Here is my code:

const {Api, JsonRpc} = require('eosjs');
const {JsSignatureProvider} = require('eosjs/dist/eosjs-jssig');
const fetch = require('node-fetch');
const {TextDecoder, TextEncoder} = require('util');
const { PrivateKey } = require('eosjs-ecc');

const privateKey1 = '5Kh3sXKTY3ed4htCD5af69MiALyk44w3PdX18smX5hDV9Kx3AAh';

const privateKeys = [privateKey1];
const publicKey = PrivateKey.fromString(privateKey1).toPublic().toString();

const signatureProvider = new JsSignatureProvider(['5Kh3sXKTY3ed4htCD5af69MiALyk44w3PdX18smX5hDV9Kx3AAh']);
const rpc = new JsonRpc('http://jungle2.cryptolions.io:80', {fetch});
const api = new Api({rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder()});

(async () => {
    const res = await api.transact({
        actions: [{
            account: 'eosio',
            name: 'newaccount',
            authorization: [{
                actor: 'winterwind12',
                permission: 'active',
            }],
            data: {
                creator: 'winterwind12',
                name: 'winterwind14',
                owner:{
                    threshold: 1,
                    keys: [{
                        key: 'EOS5ZWJYNoFUYN62iQRc77LEdY2GfmRxLUgsbtWwMstJWbJwGMPHs',
                        weight: 1
                    }],
                    accounts: [],
                    waits: []
                },
                active: {
                    threshold: 1,
                    keys: [{
                        key: 'EOS5ZWJYNoFUYN62iQRc77LEdY2GfmRxLUgsbtWwMstJWbJwGMPHs',
                        weight: 1
                    }],
                    accounts: [],
                    waits: []
                },
            },
        },
        {
            account: 'eosio',
            name: 'buyrambytes',
            authorization: [{
                actor: 'winterwind12',
                permission: 'active',
            }],
            data: {
                payer: 'winterwind12',
                receiver: 'winterwind14',
                bytes: 8192
            },
        },
        {
            account: 'eosio',
            name: 'delegatebw',
            authorization: [{
                actor: 'winterwind12',
                permission: 'active',
            }],
            data: {
                from: 'winterwind12',
                receiver: 'winterwind14',
                stake_net_quantity: '0.5000 SYS',
                stake_cpu_quantity: '0.5000 SYS',
                transfer: false,
            }
        }]
    },
    {
        blocksBehind: 3,
        expireSeconds: 30
    })

    console.log(res);
})();

After executing this, I get an error like this:

(node:20519) UnhandledPromiseRejectionWarning: Error: assertion failure with message: comparison of assets with different symbols is not allowed
    at new RpcError (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-rpcerror.js:26:28)
    at JsonRpc.<anonymous> (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:118:35)
    at step (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:36:23)
    at Object.next (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:17:53)
    at fulfilled (/home/hasnain/Projects/EOS/Test/node_modules/eosjs/dist/eosjs-jsonrpc.js:8:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:20519) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:20519) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
1

The native token symbol on the jungle testnet is EOS, not SYS...

0

If you ever get an issue with comparison of assets, it inevitably means that the symbols you have used are incorrect. This either means the symbol code is wrong (in your case using SYS instead of EOS) or it means the precision is wrong (Assets must have the same number of decimal places)

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.