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.

2 Answers 2

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

6
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
2

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.