Created
May 29, 2018 10:51
-
-
Save bobquest33/3f908b4c9181e31f877c80d4ffd4b157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install eth-crypto --save | |
// node | |
// es6 | |
// import EthCrypto from 'eth-crypto'; | |
const EthCrypto = require('eth-crypto'); | |
const solc = require('solc'); | |
// create compiled solidity-code | |
const compiled = solc.compile( | |
'contract ExampleContract {...', | |
1 | |
).contracts[':ExampleContract']; | |
const createCode = EthCrypto.txDataByCompiled( | |
compiled.interface, // abi | |
compiled.bytecode, // bytecode | |
[identity.address] // constructor-arguments | |
); | |
// now you can submit this to the blockchain | |
const serializedTx = EthCrypto.signTransaction( | |
{ | |
from: identity.address, | |
nonce: 0, | |
gasLimit: 5000000, | |
gasPrice: 5000000000, | |
data: createCode | |
}, | |
identity.privateKey | |
); | |
const receipt = await web3.eth.sendSignedTransaction(serializedTx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment