Constructor
new EthersConnection(options)
Create an instance of the EthersConnection class to manage the blockchain connection(s).
Parameters:
Name | Type | Description |
---|---|---|
options |
See CaskSDK configuration. |
- See:
Methods
(async) estimateGas(request) → {number}
Estimate gas for a transaction.
Parameters:
Name | Type | Description |
---|---|---|
request |
Object of args passed to sendTransaction |
Returns:
Estimated amount of gas needed
- Type
- number
(async) init(args)
Initialize a blockchain connection.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object | Function arguments
Properties
|
onEstimateGas(handler)
Register a handler to receive a callback when the EthersConnection estimates gas.
Parameters:
Name | Type | Description |
---|---|---|
handler |
Callback handler |
onSwitchChain(handler)
Register a handler to receive a callback when the EthersConnection switches chains.
Parameters:
Name | Type | Description |
---|---|---|
handler |
Callback handler |
onSwitchSigner(handler)
Register a handler to receive a callback when the EthersConnection switches signers.
Parameters:
Name | Type | Description |
---|---|---|
handler |
Callback handler |
(async) sendTransaction(transaction) → {string}
Send a transaction with the currently configured signer.
Parameters:
Name | Type | Description |
---|---|---|
transaction |
Transaction to send |
Returns:
TransactionResponse
- Type
- string
(async) signMessage(message) → {string}
Sign a message with the currently configured signer.
Parameters:
Name | Type | Description |
---|---|---|
message |
Message to sign |
Returns:
Signed message data
- Type
- string
(async) switchChain(chainId, signeropt)
Switch connected chain.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
chainId |
Chain ID to switch to | ||
signer |
<optional> |
Optional signer to switch to as well |
(async) switchSigner(signer)
Switch signer to use for write transactions.
Parameters:
Name | Type | Description |
---|---|---|
signer |
New signer to use |