wharfkit / antelope

Core types, client interfaces, and other tools for working with Antelope-based blockchains.
Other
42 stars 23 forks source link

"eosio_assert_message assertion failure" during account creation #96

Open dev-dantealighieri opened 6 months ago

dev-dantealighieri commented 6 months ago

when I'm trying to create an account using wharfkit/antelope library, I get the following response from the transaction broadcast.

{
  transaction_id: '41e2edec3278acba808ee6d9b761786be3862af336dc17f6732319ec893d2a01',
  processed: {
    id: '41e2edec3278acba808ee6d9b761786be3862af336dc17f6732319ec893d2a01',
    block_num: 351244143,
    block_time: '2024-01-09T15:44:49.000',
    producer_block_id: null,
    receipt: null,
    elapsed: 403,
    net_usage: 165,
    scheduled: false,
    action_traces: [ [Object], [Object] ],
    account_ram_delta: null,
    except: {
      code: 3050003,
      name: 'eosio_assert_message_exception',
      message: 'eosio_assert_message assertion failure',
      stack: [Array]
    },
    error_code: '10000000000000000000'
  }
}

I can't figure out what's the problem. I'm using an account with R1 public/private key.

I can send money transactions successfully, but account creation fails like this.

following shows how I create new account action:

contract.action(
    "newaccount",
    {
      creator: creatorUsername,
      name: newAccountName,
      owner: {
        threshold: 1,
        keys: [
          {
            key: publicKey,
            weight: 1,
          },
        ],
        accounts: [],
        waits: [],
      },
      active: {
        threshold: 1,
        keys: [
          {
            key: publicKey,
            weight: 1,
          },
        ],
        accounts: [],
        waits: [],
      },
    },
    {
      authorization: [
        {
          actor: creatorUsername,
          permission: "owner",
        },
      ],
    },
  );

and the following shows how I create buy ram action

contract.action(
    "buyrambytes",
    {
      payer: payerUsername,
      receiver: receiverUsername,
      bytes: ramBytes,
    },
    {
      authorization: [
        {
          actor: payerUsername,
          permission: "owner",
        },
      ],
    },
  );

the contract here is coming from import { Contract } from '@wharfkit/contract';

aaroncox commented 5 months ago

Sorry it took me a bit to get around to this. I managed to basically reproduce what you were trying to do and it appears that it was successful.

https://jungle4.eosq.eosnation.io/tx/94eb6df9111305ce986254b1670b79e42e084e34226d9cbdbb9c89cf6809d795

My best guess is something inside one of the variables in the code above, whether it be the account name, public key, bytes received or something else is at fault here. The code itself should be working properly but the inputs are mixed up somehow.

Below is the code that I just used to successfully create the account above.

const creatorUsername = 'wharfkittest'
const session = new Session({
    chain: Chains.Jungle4,
    walletPlugin: new WalletPluginPrivateKey(
        'PRIVATE_KEY_HERE'
    ), // or use a wallet plugin
    actor: creatorUsername,
    permission: 'active',
})
const newAccountName = 'test2334test'
const newPrivateKey = PrivateKey.generate('R1')
const newPublicKey = newPrivateKey.toPublic()
const action1 = systemContract.action(
    'newaccount',
    {
        creator: creatorUsername,
        name: newAccountName,
        owner: {
            threshold: 1,
            keys: [
                {
                    key: newPublicKey,
                    weight: 1,
                },
            ],
            accounts: [],
            waits: [],
        },
        active: {
            threshold: 1,
            keys: [
                {
                    key: newPublicKey,
                    weight: 1,
                },
            ],
            accounts: [],
            waits: [],
        },
    },
    {
        authorization: [
            {
                actor: creatorUsername,
                permission: 'active',
            },
        ],
    }
)
const action2 = systemContract.action('buyrambytes', {
    payer: creatorUsername,
    receiver: newAccountName,
    bytes: 4000,
})
const result = await session.transact({actions: [action1, action2]})
console.log(result)