dappId
- [REQUIRED]dappId
by visiting the Blocknative account page and creating a free account.system
- [OPTIONAL]bitcoin
and ethereum
are supported. Defaults to ethereum
if no value is passed in.networkId
- [REQUIRED]ethereum
for system
):1
Main Network3
Ropsten Test Network4
Rinkeby Test Network5
Goerli Test Network42
Kovan Test Network56
Binance Smart Chan Main Network100
xDai POA Network137
Polygon Matic Mainnet Network250
Fantom Opera Mainnet Networkbitcoin
for system
):1
Main Network2
Testnet NetworktransactionHandlers
- [OPTIONAL]ws
- [OPTIONAL]sdk
in a server environment, there won't be a native WebSocket instance available for the sdk
to use, so you will need to pass one in. You can use any WebSocket library that you prefer as long as it correctly implements the WebSocket specifications. We recommend ws.name
- [OPTIONAL]sdk
on the same client, passing in a name property allows the sdk
to properly manage persistent state.onopen
- [OPTIONAL]onerror
- [OPTIONAL]message
: String
- The error message, describing what went wrongerror
: ErrorObject
- An error object if ine exist (for instance a WebSocket error)transaction
: String
- The hash
or txid
passed to the call to transaction
that caused the erroraccount
: String
- The address
passed to the call to account
that caused the errorondown
- [OPTIONAL]onreopen
- [OPTIONAL]onclose
- [OPTIONAL]transaction
function:emitter
is used to listen for status updates. See the Emitter Section for details on how to use the emitter
object to handle specific transaction state changes.details
object contains the initial transaction details which are useful for internal tracking.account
method:account
will include an event emitter
that you can use to listen for those events and a details object which includes the address
that is being watched.unsubscribe
method:dappId
. To log an event, simple call event
with a categoryCode
and an eventCode
, both of which can be any String
that you like:account
and transaction
and is used to listen to status updates via callbacks registered for specific event codes.eventCode
string of the event that you would like to register a callback for. For a list of the valid event codes, see the event codes section.transaction
emitters will be included in the object that the global transactionHandlers
are called with under the emitterResult
property.off
method on the emitter to remove your callback listener:transactionHandlers
array will be called with the following transaction object:confirmed
notifications when a watchedAddress
is detected in the internal transactions of a contract call. In this case, the confirmed
transaction object will include details of the internal transactions and balance changes resulting from those internal transactions. Fields are not ordered. internalTransactions
netBalanceChanges
internalTransactions
array contains details on each internal transaction executed by the contract call of the parent (main) transaction. Fields are not ordered. type
CALL
, DELEGATECALL
, STATICCALL
, CALLCODE
)from
to
input
0x
. For contract calls, this value contains the contract method signature and params as a hex string.gas
gasUsed
value
to
address from parent (main) transaction from
address.contractCall
transfer
or transferFrom
call, the contractCall
object will include an additional field, contractAlias
with the symbol of the token transferred.netBalanceChanges
object contains details of all the balance changes resulting from the internal transactions details in the internalTransactions
array.<address>
counterparty
asset
type
and symbol
.delta
<address>
. Outgoing value is represented as a negative balance change and incoming value is represented as a positive balance changetype
symbol
breakdown
<address>
for the current asset
counterparty
<address>
amount
counterparty
all
: Will be called for all events that are associated with that emitter. If a more specific listener exists for that event, then that will be called instead. This is useful to catch any remaining events that you haven't specified a handler fortxSent
: Transaction has been sent to the networktxPool
: Transaction was detected in the "pending" area of the mempool and is eligible for inclusion in a blocktxPoolSimulation
: Transaction was detected in the "pending" area of the mempool and is eligible for inclusion in a block and has been simulated against the latest blocktxStuck
: Transaction was detected in the "queued" area of the mempool and is not eligible for inclusion in a blocktxConfirmed
: Transaction has been minedtxFailed
: Transaction has failedtxSpeedUp
: A new transaction has been submitted with the same nonce and a higher gas price, replacing the original transactiontxCancel
: A new transaction has been submitted with the same nonce, a higher gas price, a value of zero and sent to an external address (not a contract)txDropped
: Transaction was dropped from the mempool without being added to a blockconfiguration
function can be used to send a configuration that will be scoped globally or to a particular address:scope
- [required]'global'
configuration so that you can filter all events for all addresses that you are watching or a valid Ethereum address to scope the configuration to events that occur only on that address.filters
- [optional]jsql
a JavaScript query language to filter events. Documentation for how to create filter queries can be found hereabi
- [optional]scope
is an Ethereum address, then watchAddress
can be set to true so that the Blocknative server can automatically watch the address in scope, rather than needing to send an extra call to blocknative.account
scope
establishes the context in which a filter is applied. The global
scope applies the filter to all transactions/addresses watched. Therefore a global
scope only supports generic transaction elements. A scope
set to an address can include filters, such as methodName,
that are specific to the contract at that address. Similarly, the abi
field only works for a contract specific scope
.configuration.json
, sdk-setup.js
) downloaded, drop them in to your project directory. They can then be imported and setup with the SDK: