2

Is there any command or utility to deploy contract from .sol file to test-net? I've seen there is JSON API, so I can write some code to implement this. But isn't it done already?

Thanx.

1

Truffle Framework is the most popular tool that is available now to perform such a task. All you need is to copy your contract code into contracts directory, add an entry into migration file and run:

truffle migrate

The procedure is explained in details here.

There are lots of tutorials and good docs available if you get lost.

I hope it helped

1

You can use node or geth to deploy a contract.

Node example:

npm install ethereum-js-testrpc web3
npm install solc

Run the test rpc server

node_modules/.bin/testrpc

Console

Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
code = fs.readFileSync('Voting.sol').toString()
solc = require('solc')
compiledCode = solc.compile(code)
abiDefinition = JSON.parse(compiledCode.contracts[':NameofYourClass'].interface)
Contract = web3.eth.contract(abiDefinition)
byteCode = compiledCode.contracts[':NameofYourClass'].bytecode
deployedContract = Contract.new(args,to,init,your,contract)
deployedContract.address

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.