3

I'm trying to transfer an ERC20 token from account A to account B. Account A deployed the contract and owns all tokens.

Looks like I'm missing something very obvious.

Every time I try to transfer tokens from one account to another, I get a error. Here is an example of erroneous transaction.

Addresses in question:

I'm doing the following (the code is in Ruby, but should be self-explanatory):

require 'ethereum'

value = 14

account_a_address = "0xd8e05701eFf33acfDA0A8e24C04070347703c72C"
account_b_address = "0x3A70Ceac36c8111a95b573d76aD75B7ba898662b"
contract_address = "0x1caf5380b7adc2e4e93c2828f895693ff38c3947"

Ethereum::Singleton.setup do |c|
  c.default_account = account_a_address
end

Ethereum::Contract.create(
  file: "/Users/gmile/projects/ico-scripts/contracts/02-14-2018-1518620826/contract_text.sol",
  address: contract_address
)

contract = EugeneToken.new
tx = contract.transact.transfer(account_b_address, value * 1_000_000_00)

puts tx.id

For some reason the transaction is qualified as Contract Creation. Why?

enter image description here

I double-checked with the documentation for ethereum.rb Ruby gem. The readme states that I can use the contract from blockchain by specifying an address of the contract deployed, as well a path to .sol file as parameters to Ethereum::Contract.create() call.

4
  • Seems to be like contract creation is failed Feb 15, 2018 at 14:32
  • @Jitendra Kumar. Balla but I don't intend to create a new contract. I'm trying to use existing contract, deployed on the network, as a basis for my transaction. Looks like I'm missing something obvious. Feb 15, 2018 at 14:33
  • Your contract is invalid. Valid contract has contract code. Your contract doesn't have bytecode. So EVM will treat as a invalid contract. Check your rb file. Feb 15, 2018 at 14:36
  • But it is valid, isn't it? ropsten.etherscan.io/address/… Or do you mean the contract logic is somehow malformed? Feb 15, 2018 at 14:48

1 Answer 1

2

Figured this out.

The problem was that I had multiple contracts in the .sol file, where the actual main contract was being assembled (inherited?) from several smaller ones. This tutorial1_contract.sol file served as a template from which I made my own contract.

To fix this, I specified the contract_index to the Ethereum::Contract.create() call:

Ethereum::Contract.create(
  file: "/Users/gmile/projects/ico-scripts/contracts/02-14-2018-1518620826/contract_text.sol",
  address: contract_address,
  contract_index: 2
)
2
  • Please accept your own answer :-) (There might be an imposed delay of 48 hours, in which case, come back then and do so... ) Feb 15, 2018 at 16:45
  • @RichardHorrocks will do Feb 15, 2018 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.