简体   繁体   中英

How can I deploy a smart contract to RSK without using Truffle?

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?

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:

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 of gas .
  • Use the eth_gasPrice RPC to obtain the value of gasPrice .

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM