Webhooks
Send a simple JSON or YAML payload that can:
- Compile and deploy contracts from in-line Solidity source code
- Deploy contracts from bytecode
- Asynchronously deliver transactions to your ethereum node over our Kafka backbone
- Invoke solidity transactions without needing to first install an ABI
You get a response immediately, including an id
that you can query for results in the receipt store later.
The same reliable transport as is used on
POST
methods of the installed REST Gateway generated interfaces, whenkld-sync
is unset.
Ideal for use as a webhook endpoint for an integration tool that can emit sevents over HTTPS. Also useful if your application wants to construct the full details for the transaction to sent to a contract, or install a new contract, without first teaching the REST API Gateway about the Solidity interface (ABI).
Paths
There are two variations of the webhook:
- Fire & forget on
/
and/fasthook
: responds as soon as the message is sent to the Kafka client library - Kafka acknowledged on
/hook
: responds only once Kafka has acknowledged receipt of the message
Body
You can send either JSON or YAML, containing the following fields:
Field | type | Description |
---|---|---|
headers |
object | Required: Headers |
headers.type |
string | Required: DeployContract or SendTransaction |
from |
string | Required: The hex from address to sign the transaction (0x optional) |
to |
string | The target hex address (0x optional) - required for SendTransaction only |
methodName |
string | The method to invoke - required for SendTransaction only |
params |
array | Array of input parameters, with type and value |
params[].type |
string | Ethereum type such as uint256 for the parameter |
params[].value |
mixed | Value for the parameter, in an appropriate type for the input. We recommend strings for numeric types, but accept either |
soldity |
string | Solidity contract source (SendTransaction only) |
contractName |
string | When there are multiple contracts in the compiler output, this field is required to select the contract to deploy |
compilerVersion |
string | Compiler to use. Default: 0.4 (for compatibility)Recommend setting to 0.5 |
compiled |
base64 | Pre-compiled contract binary - instead of solidity |
gas |
string | Maximum gas to consume. Recommend leaving unset for automatic gas estimation |
gasPrice |
string | Optionally offer a non-zero gas price for the transaction |
value |
string | Optionally send some of the chain's native Ether with the transaction |
nonce |
string | Optionally set an explicit nonce for the transaction. Recommend leaving unset for automatic nonce management |
privateFrom |
string | Tessera / Orion Private Transactions: private-from address |
privateFor |
array | Tessera / Orion Private Transactions: private-for addresses |
Example Contract Deployment Transaction
headers:
type: DeployContract
from: "0xb863185C6361A226Edc3Ec11EB891a2CfDDc5685"
params:
- type: "uint256"
value: "12345"
compilerVersion: '0.5'
solidity: |-
pragma solidity >=0.4.24 <0.6.0;
/**
* @title Simple Storage
* @dev Read and write values to the chain
*/
contract simplestorage {
uint public storedData;
/**
* @dev Constructor sets the default value
* @param initVal The initial value
*/
constructor(uint initVal) public {
storedData = initVal;
}
/**
* @dev Set the value
* @param x The new value
*/
function set(uint x) public {
storedData = x;
}
/**
* @dev Get the value
*/
function get() public view returns (uint retVal) {
return storedData;
}
}
Example Method Invocation Transaction
headers:
type: SendTransaction
from: "0xb863185C6361A226Edc3Ec11EB891a2CfDDc5685"
to: "0xdceb21933100f4c48d0365db73506ea2dd91e07b"
methodName: set
params:
- type: "uint256"
value: "99999"