Skip to content

Instantly share code, notes, and snippets.

@qianbin
Last active March 6, 2019 06:27
Show Gist options
  • Save qianbin/3d4734643e8446f76f06cabce0c0c948 to your computer and use it in GitHub Desktop.
Save qianbin/3d4734643e8446f76f06cabce0c0c948 to your computer and use it in GitHub Desktop.
deployment data for contract with constructor arguments
import { abi } from 'thor-devkit'
// assume we have a demo contract
// contract DemoContract {
// constructor(int arg) public {
// }
// }
const byteCode = '0x....'
const constructorABI = {
"inputs": [
{
"name": "arg",
"type": "int256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
}
const coder = new abi.Function(constructorABI)
const dataToDeploy = byteCode + coder.encode(1).slice(10 /* remove 0x prefix and 4bytes sig */)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment