Deployer
Deployer
Deployer functionality
The main functionality the deployer exposes is (obviously) the ability to deploy compiled contract.
This is achieved through the deploy(contract, [libraries], [params])
function.
deploy(contract, [libraries], [params])
Parameters:
contract
- descriptor object for contract to be deployed. Moredetails below
libraries
- key-value object containing all libraries which willbe linked to the contract.
params
- the constructor params you'd need to pass on deploy (ifthere are any)
The contract is descriptor object that needs to have atleast the following three fields:
contractName
- the name of the contractabi
- the abi interface of the contractbytecode
- the compiled bytecode
The easiest way to get such descriptor is to compile your solidity files via etherlime compile
The libraries object should be in the following format:
If the contract to be deployed doesn't contains any libraries, {}
, undefined
, null
, false
or 0
can be passed. For convenience we have made the deploy function to work even without this parameter passed.
Example
Linking libraries
Skipping linking on contract without arguments
Skipping linking on contract with arguments
deployAndVerify(platform, contract, [libraries], [params])
The main functionality the deployAndVerify exposes is (obviously) the ability to deploy and then verify compiled contract on Etherscan or Blockscout platforms. This method exposes the same features as deploy
method, but in addition automatically verifies the deployed smart contract using Etherscan/Blockscout APIs.
In order to use the deployAndVerify
method of the deployer for Etherscan platform, an API Key is required. You can create your Etherscan API Key here.
Parameters:
platform
- point the platform you want to verify your contract. Choices:etherscan
,blockscout
contract
- descriptor object for contract to be deployed. Moredetails below
libraries
- key-value object containing all libraries which willbe linked to the contract.
params
- the constructor params you'd need to pass on deploy (ifthere are any)
The deployment method reads the API Key (needed only for using Etherscan) form the deployer defaultOverrides
object.
Passing API Key to the deployer:
Passing the API Key to the
defaultOverrides
object:
Setting the API Key through the deployer
setVerifierApiKey
setter:
Passing the API Key from
etherlime deploy
command with optional parameter
Network is automatically detected based on the network that the deployer is set to deploy. The supported networks are:
mainnet
ropsten
rinkeby
kovan
goerli
estimateGas(contract, [libraries], [params])
Estimates the gas that this transaction is going to cost you.
Parameters:
contract
- descriptor object for contract to be deployedlibraries
- key-value object containing all libraries which willbe linked to the contract.
params
- the constructor params you'd need to pass on deploy (ifthere are any)
The contract is descriptor object is the same as above.
Example :
Deployers
InfuraPrivateKeyDeployer
Parameters:
privateKey
- The private key to the deployment wallet/signerinstance
network
- network as found inethers.providers.networks
apiKey
- your Infura API keydefaultOverrides
- [Optional] object overriding the deploymentsettings for
gasPrice
,gasLimit
andchainId
.
Setters
provider . setPrivateKey (privateKey)
privateKey
- The private key to the deployment wallet/signerinstance
provider . setNetwork (network)
network
- network as found inethers.providers.networks
provider . setApiKey (apiKey)
apiKey
- your Infura API keyprovider . setDefaultOverrides (defaultOverrides)
defaultOverrides
- object overriding the deployment settingsfor
gasPrice
,gasLimit
andchainId
.provider . setSigner (signer)
signer
- ethers.Wallet instanceprovider . setProvider (provider)
provider
- ethers.provider instance
Example :
JSONRPCPrivateKeyDeployer
Parameters:
privateKey
- The private key to the deployment wallet/signerinstance
nodeUrl
- the url to the node you are trying to connect (local orremote). The
nodeUrl
may also be specified as an object with properties:url — the JSON-RPC URL (required)
user — a username to use for Basic Authentication [optional]
password — a password to use for Basic Authentication [optional]
allowInsecure — allow Basic Authentication over an insecure HTTP network (default: false)
defaultOverrides
- [Optional] object overriding the deploymentsettings for
gasPrice
,gasLimit
andchainId
.
Setters
provider . setPrivateKey (privateKey)
privateKey
- The private key to the deployment wallet/signerinstance
provider . setNodeUrl (nodeUrl)
nodeUrl
- the url to the node you are trying to connect(local or remote)
provider . setDefaultOverrides (defaultOverrides)
defaultOverrides
- object overriding the deployment settingsfor
gasPrice
,gasLimit
andchainId
.provider . setSigner (signer)
signer
- ethers.Wallet instanceprovider . setProvider (provider)
provider
- ethers.provider instance
Example :
EtherlimeGanacheDeployer
Parameters:
privateKey
- [Optional] The private key to the deploymentwallet/signer instance. Defauts to the first one in the
etherlime ganache
port
- [Optional] the port you've ran the etherlime ganache on.Defaults to 8545.
defaultOverrides
- [Optional] object overriding the deploymentsettings for
gasPrice
,gasLimit
andchainId
.
This deployer only works with etherlime ganache
Setters
provider . setPrivateKey (privateKey)
privateKey
- The private key to the deployment wallet/signerinstance
provider . setPort (port)
port
- the port you've ran the etherlime ganache on.provider . setDefaultOverrides (defaultOverrides)
defaultOverrides
- object overriding the deployment settingsfor
gasPrice
,gasLimit
andchainId
.provider . setNodeUrl (nodeUrl)
nodeUrl
- the url to the node you are trying to connect(local or remote)
provider . setSigner (signer)
signer
- ethers.Wallet instanceprovider . setProvider (provider)
provider
- ethers.provider instance
Example :
ZosJSONRPCPrivateKeyDeployer
ZosJSONRPCPrivateKeyDeployer is a powerful object giving you the ability to deploy and operate with a smart contract on ZeppelinOS platform.
To use it, first you need to add etherlime-zos-deployer
as a dependency in your project with npm install
.
Parameters:
privateKey
- The private key to the deployment wallet/signer instancenodeUrl
- the url to the node you are trying to connect (local or remote)defaultOverrides
- [Optional] object overriding the deployment settings forgasPrice
,gasLimit
andchainId
.
Setters
provider.setPrivateKey(privateKey)
privateKey
- The private key to the deployment wallet/signer instanceprovider.setNodeUrl(nodeUrl)
nodeUrl
- the url to the node you are trying to connect (local or remote)provider.setDefaultOverrides(defaultOverrides)
defaultOverrides
- object overriding the deployment settings forgasPrice
,gasLimit
andchainId
.provider.setSigner(signer)
signer
- ethers.Wallet instanceprovider.setProvider(provider)
provider
- ethers.provider instance
Example
Last updated