smart-contract-deployer
A node module to compile and deploy smart contracts programmatically on the ethereum blockchain.
Installation
npm install smart-contract-deployer
Usage
Create a valid web3
instance, either using a client like geth for production
const Web3 = ;const web3 = 'ipcpath' ;
or TestRPC for testing development.
const TestRPC = ;const Web3 = ;const web3 = TestRPC;
Specify the address from which the contracts should be deployed.
const address = web3ethcoinbase;
Specify the password associated with the previous address. This value is optional, and if it is not supplied, unlockAccount
will not be called during the deployment process. If TestRPC has been specified as the web3
provider, by all means, leave this value blank.
const password = 'addressPassword';
Specify the amount of gas to spend in any transaction.
const gas = 500000;
Import the deployer module and create and instance of deployer
passing by constructor as an object the previous values.
const Deployer = ;const deployer = web3: web3 address: address password: password gas: gas;
Get the sources of your contracts to be compiled.
const fs = ; const sources = 'SolContractA.sol': fs 'SolContractB.sol': fs
Set the params constructor if the contract expects some values to be initialized.
const paramsConstructor = 'SolContractA': 'a' 'b' 'c';
Specify which one of the sources requires to be deployed.
const deployments = 'SolContractA';
And finally, call deployContracts
passing as an argument the previous values.
return deployer ;
Optionally, call logs
supplying a function as a callback to subscribe to the outputs log.
deployer;