ContractMethodSender

The ContractMethodSender (short Sender) class is a part of the ContractClient to eventually create blockchain transactions. They are usually created for a ContractClient class on its initialization (e.g. the ColonyClient) and are associated with one single method on the smart contract.

For more info see the ContractClient docs.

Instance methods

estimate(inputValues)

Given named input values, it will estimate the Gas cost of the transaction generated for the associated smart contract method.

Arguments

inputValues { [string]: any } - Any key value pair of contract input parameters

Returns

Promise<BigNumber> - Promise that resolves to a BigNumber object which represents the estimated Gas cost.

send(inputValues, options)

Given named input values, signs and sends off the transaction using by calling the associated smart contract method with the input values using the provider attached to the ContractClient. It returns a ContractResponse object which may contain the transaction metadata as well as event data (if applicable). For more information see the ContractClient docs.

Arguments

inputValues { [string]: any } - Any key value pair of contract input parameters

options SendOptions - Custom options to use for this transaction. SendOptions being an object with the following possible properties:

OptionTypeDescription
timeoutMsnumberMilliseconds to wait until this transaction will time out
waitForMiningbooleanIf true, it will wait for the transaction to be mined before resolving the resulting promise (default: true)
gasLimitBigNumberSets the maximum gas limit for the transaction
gasPriceBigNumberThe price in wei per gas unit
noncenumberThe transaction nonce
valueBigNumberThe amount in wei that the transaction will send

Returns

Promise<ContractResponse> - With ContractResponse being an object with the following properties (see also Senders:

with waitForMining: true:

PropertyTypeDescription
successfulbooleanIndicates whether the transaction was executed successfully
eventDataObjectContains eventData emitted by the smart contract (see docs of the particular contract client)
metaObjectContains the transaction and a receipt object passed on by the used ethereum adapter

with waitForMining: false:

PropertyTypeDescription
successfulPromisePromise Just like above but will only be resolved when mined
eventDataPromiseObjectJust like above but will only be resolved when event data is emitted
metaObjectJust like above execpt the receipt is receiptPromise and will be resolved when mined