I compiled my code using the command line:

solc --bin file.sol

It creates a binary like: 653980298309f02f03.......

What's the next step? I want to deploy it using the same command line.


Step 1: You will also need the ABI; you can run the following command to get this:

solc --bin file.sol

Step 2: run an Ethereum client, such as Geth, locally (if connecting to one of the test networks or mainnet, wait for it to fully sync) with the console enabled e.g.

geth --rinkeby --fast console

step 3: on the Ethereum node create a JS object of your ABI (mostly just for convenience and clarity):

var contractJson = [{"constant":true...}]
Note: abi truncated for brevity

step 4: call the web3.js contract function to create a Contract object using your ABI JS object

var contract = eth.contract(contractJson)

Step 5: unlock your account in order to be able to sign the transaction we are about to create (if you don't have an account then you will need to create one and give it some Ether...)


Step 6: deploy your contract on Ethereum by creating a transcation using the bin / bytecode data from above:

contract.new({from: eth.accounts[0], data: "0x653980298309f02f03......."})
Note: bytecode truncated for brevity

Step 7: lock your account


Make a note of the transaction id and the contract address output from Step 6 and then wait for the transaction to be mined. You can check with in the console using:

eth.getTransaction("tx id from step 6")


via geth console :

eth.sendTransaction({from:sender, data:'your bytecode'})

via web3js:

var code = "603d80600c6000396000f3007c01000000000000000000........57005b6007600435028060005260206000f3";
web3.eth.sendTransaction({data: code}, function(err, transactionHash) {
if (!err)
console.log(transactionHash); // "0x7f9fade1c0d57a7af66ab4ead7c2eb7b11a91385"

via RPC (CURL)

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{from:**,data:'your bytecode',gas:***}],"id":1}'

For more details you can have a look at this documentation.

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.