After compiling a Solidity file using solc
, how can I deploy the output bytecode as a smart contract to RSK?
I know how to do this using Truffle already, but what alternatives are there available for this task?
2 Answers
RSK is (mostly) compatible with Ethereum. In particular, for dev tools, it has JSON-RPC compatibility plus VM compatibility. So if you are a Ethereum developer, you can use tools/ libs that you are familiar with. Here are several methods, apart from Truffle:
- using Geth console and Remix, or
- using Metamask/Nifty and Remix, or
- using MyCrypto or MyEtherWallet contract deploy tools (if you have the contract bytecode).
If you want to do this manually,
you can do so using the terminal by
sending a transaction using curl
via JSON-RPC like this:
curl \
-X POST \
-H "Content-Type:application/json" \
--data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"FROM_ADDRESS","to":"0x00","gasPrice":"0x3938700","gas":"0x67C28", "data":"SIGNED_CONTRACT_DEPLOYMENT_BYTECODE"}],"id":1}' \
http://localhost:4444
- Use the
eth_estimateGas
RPC to obtain the value ofgas
. - Use the
eth_gasPrice
RPC to obtain the value ofgasPrice
.
Note that the above command assumes that you have RSKj running on localhost
.
Also note that just like any other transaction
which modifies the state of the blockchain,
you will need to sign the deployment transaction as well,
in order to produce SIGNED_CONTRACT_DEPLOYMENT_BYTECODE
.
You can use the eth_sign
RPC for this,
or the equivalent method in your wallet.

- 27,371
- 47
- 154
- 243
Yes, it is good to know what happen in these situations. Short answer: you send a transaction, to field is empty, data field containts the bytecode of the compiled contract CONCATENATED with the ABI encoded arguments for constructor, if any
Usually, I write my own utilities (in NodeJS, to be cross platform), to interact with an Ethereum/RSK node. You can explore the code of the implemention of client.deploy in my personal project https://github.com/ajlopez/rskapi
Also, you can check the implementation of my command line tools (based on the above library) https://github.com/ajlopez/rskclitools#deploy-a-contract
An code example in https://github.com/ajlopez/EthFaucet/tree/master/commands (see execute setup)
I will add the feature to provide directly the bytecode to deploy command, and in a few days, I will write a post with a bit more organized description

- 106
- 2
-
awesome! `client.deploy` sounds like a good option to try! – bguiz May 17 '21 at 10:40