Skip to content

Instantly share code, notes, and snippets.

@bobquest33
Created May 29, 2018 10:51
Show Gist options
  • Save bobquest33/3f908b4c9181e31f877c80d4ffd4b157 to your computer and use it in GitHub Desktop.
Save bobquest33/3f908b4c9181e31f877c80d4ffd4b157 to your computer and use it in GitHub Desktop.
// 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