hswick / exw3

High level Ethereum RPC Client for Elixir
Apache License 2.0
151 stars 45 forks source link

Assertion error sending to contract... #113

Closed somoza closed 2 years ago

somoza commented 2 years ago
    accounts = ExW3.accounts()
    simple_storage_abi = ExW3.Abi.load_abi("abi/MyContract.abi")

    ExW3.Contract.start_link
    ExW3.Contract.register(:MyContract, abi: simple_storage_abi)
    ExW3.Contract.at(:MyContract, Application.get_env(:ethereumex, :contract_address) |> Base.encode16(case: :lower) )

    ExW3.Contract.send(:MyContract, :MyFunction, [1, "Foo"], %{from: Enum.at(accounts, 0), gas: 50_000})

"AssertionError [ERR_ASSERTION]: The field to must have byte length of 20\n at Transaction.setter [as to] (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/ethereumjs-util/src/object.ts:57:9)\n at /tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/utils/transaction.js:116:23\n at Array.forEach ()\n at initData (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/utils/transaction.js:110:18)\n at new Transaction (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/utils/transaction.js:168:5)\n at Function.fromJSON (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/utils/transaction.js:228:16)\n at StateManager.queueTransaction (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/statemanager.js:371:22)\n at GethApiDouble.eth_sendTransaction (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/subproviders/geth_api_double.js:325:14)\n at GethApiDouble.handleRequest (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/subproviders/geth_api_double.js:109:10)\n at next (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at GethDefaults.handleRequest (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/subproviders/gethdefaults.js:15:12)\n at next (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at SubscriptionSubprovider.FilterSubprovider.handleRequest (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/filters.js:89:7)\n at SubscriptionSubprovider.handleRequest (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/subscriptions.js:137:49)\n at next (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at DelayedBlockFilter.handleRequest (/tmp/.mount_ganachnT4wTL/resources/static/node/node_modules/ganache-core/lib/subproviders/delayedblockfilter.js:31:3)"

somoza commented 2 years ago

I had to add paramter to: on the map in order to get it working...

%{from: Enum.at(accounts, 0), to: Application.get_env(:ethereumex, :contract_address), gas: 50_000})

Does README needs an update?