0

Disclaimer: it is self Q&A post to help others with issue I faced with. Please note this is a possible solution that works for me, there is might be a better way to solve the issue.

The issue:

Can not compile the contract in geth console since 1.6.0 reference to the issue tracker

0

Solution:

Compile the contract on your machine before go into geth. Move your contract to data directory you use to map your node. Load your contract from geth console

  1. Compile the contract on your machine before go into console

    $ touch Contract.sol

    $ echo "var contractOutput=solc --optimize --combined-json abi,bin,interface Contract.sol" > contract.js (pay attention to `` quotes)

  2. Move contract to data directory you use to run the node (btw, I use docker to run it)

    $ cp contract.js ~/Workspace/Ether/datadir/contracts

  3. Run your node over docker and provide mapping on your data directory

    docker run -it -p 8545:8545 -p 30303:30303 -v /home/user/Workspace/Ether/datadir:/root/datadir user/my-ether-node /bin/bash

  4. Run console

    geth --datadir /root/datadir/ --networkid 1234 --port 30303 --rpcport 8545 --rpc --rpcapi eth,web3,personal,net --rpcaddr 0.0.0.0 console

  5. Load the contract

    loadScript('/root/datadir/contracts/contract.js')

The link on guide which should help you with initial configuration of ethereum and start with nodes

  • How would I call a function from contract.js within the Geth console? My contract.js looks like: var contractOutput = {"contracts" : {"contracts/Contract.sol:TestContract" : {"abi": ..., "bin": ...}, ...}} – Evan Kaminsky Nov 5 '18 at 23:35
  • It was almost an year since my last project on ethereum. I checked my notes, here is an example via Truffle (it is preffered way): Test.deployed().then(instance => instance.sell( accounts[1], {from: accounts[0], value: web3.toWei(1, 'ether') } )) If you want to do this on low level please refer this blog post medium.com/@gus_tavo_guim/… – Gleichmut Nov 6 '18 at 5:49

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.