@integraledger/lcp/evm
The exports of @integraledger/lcp/evm.
Classes
ReaderError
Extends
Error
Constructors
Constructor
new ReaderError(
kind,message?):ReaderError
Parameters
| Parameter | Type |
|---|---|
kind | "transport" | "timeout" | "too-large" | "malformed" |
message? | string |
Returns
Overrides
Error.constructor
Properties
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
Interfaces
Delegation
Properties
| Property | Type |
|---|---|
authority | `0x${string}` |
caveats | object[] |
delegate | `0x${string}` |
delegator | `0x${string}` |
salt | `0x${string}` |
signature | `0x${string}` |
Eip3009TypedData
Properties
| Property | Type |
|---|---|
domain | object |
domain.chainId | number |
domain.name | string |
domain.verifyingContract | `0x${string}` |
domain.version | string |
message | object |
message.from | `0x${string}` |
message.nonce | `0x${string}` |
message.to | `0x${string}` |
message.validAfter | bigint |
message.validBefore | bigint |
message.value | bigint |
primaryType | "TransferWithAuthorization" |
types | object |
types.EIP712Domain | Field[] |
types.TransferWithAuthorization | Field[] |
EvmLog
One receipt log: the emitter, its topics and its data.
Properties
EvmReader
Bounded, read-only calls against one network's endpoint. Every failure rejects with ReaderError.
Properties
Methods
blockNumber()
blockNumber(
tag):Promise<bigint>
eth_getBlockByNumber(tag, false).number.
Parameters
| Parameter | Type |
|---|---|
tag | "safe" | "finalized" |
Returns
Promise<bigint>
receipt()
receipt(
tx):Promise<EvmReceipt|null>
eth_getTransactionReceipt; null when the node holds none.
Parameters
| Parameter | Type |
|---|---|
tx | `0x${string}` |
Returns
Promise<EvmReceipt | null>
transaction()
transaction(
tx):Promise<EvmTransaction|null>
eth_getTransactionByHash: the recipient (null for a contract creation) and the calldata; null when none.
Parameters
| Parameter | Type |
|---|---|
tx | `0x${string}` |
Returns
Promise<EvmTransaction | null>
EvmReceipt
Properties
| Property | Type |
|---|---|
blockNumber | bigint |
logs | readonly EvmLog[] |
status | 0 | 1 |
EvmRef
What the issuer records at claim for an EVM payment: read keys only.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
bindingLog? | { address: `0x${string}`; topic0: `0x${string}`; value: `0x${string}`; } & ({ index: 2 | 1 | 3; } | { dataWord: number; }) | The log carrying H or its commitment: in topic index, or in 32-byte data word dataWord. |
network | `eip155:${string}` | HederaNetwork | - |
search? | object | The log filter that finds the transaction when none is named; absent, only a named transaction is read. |
search.address | `0x${string}` | - |
search.topics | readonly (`0x${string}` | null)[] | - |
settleBy? | string | Decimal Unix seconds after which the payment can no longer execute. |
transferLog? | object | The token transfer this payment made, identified by the digest of the named fields. |
transferLog.address | `0x${string}` | - |
transferLog.digest | `0x${string}` | - |
transferLog.identity | TransferIdentity | - |
transferLog.topic0 | `0x${string}` | - |
EvmTransaction
A transaction as eth_getTransactionByHash gives it: to and input.
Properties
EvmTxRef
Properties
Field
Properties
PaymentInfo
Properties
Permit2TypedData
Properties
| Property | Type |
|---|---|
domain | object |
domain.chainId | number |
domain.name | "Permit2" |
domain.verifyingContract | `0x${string}` |
message | object |
message.deadline | bigint |
message.nonce | bigint |
message.permitted | { amount: bigint; token: `0x${string}`; } | object[] |
message.spender | `0x${string}` |
message.witness? | object |
primaryType | "PermitTransferFrom" | "PermitWitnessTransferFrom" | "PermitBatchWitnessTransferFrom" |
types | object |
types.EIP712Domain | Field[] |
types.TokenPermissions | Field[] |
Type Aliases
Eip155
Eip155 =
`eip155:${string}`
CAIP-2 for EVM chains; the reference is the decimal chain id.
Eip3009Ref
Eip3009Ref =
EvmRef&object
What a settlement reference holds for an EIP-3009 payment: read keys only. It is an EvmRef naming the
AuthorizationUsed log and the transfer's identity, with the token, validBefore and the transfer digest.
Type Declaration
| Name | Type | Description |
|---|---|---|
asset | Hex | - |
idDigest | Hex | - |
maxTimeoutSeconds | number | The option's maxTimeoutSeconds: the authorization was signed no earlier than validBefore less this. |
network | Eip155 | - |
validBefore | string | - |
EvmBreadthStatus
EvmBreadthStatus =
EvmStatus| {state:"failed";why:"binding-log-not-found"|"transfer-not-found"|"receive-policy-blocked"; }
EvmStatus
EvmStatus = {
blockNumber:bigint;finality:"latest"|"safe"|"finalized";state:"settled"; } | {state:"pending";why:"not-found"|"unreadable"; } | {state:"failed";why:"reverted"|"authorization-not-used"; }
Hex
Hex =
`0x${string}`
ReceiveTypedData
ReceiveTypedData =
Omit<Eip3009TypedData,"primaryType"|"types"> &object
EIP-3009's ReceiveWithAuthorization: the same fields as TransferWithAuthorization, for a payee contract.
Type Declaration
| Name | Type |
|---|---|
primaryType | "ReceiveWithAuthorization" |
types | object |
types.EIP712Domain | Field[] |
types.ReceiveWithAuthorization | Field[] |
TransferIdentity
TransferIdentity =
"from,to,value"|"from,to"|"from"|"to,value"|"to"
Variables
AUTHORIZATION_USED_TOPIC
constAUTHORIZATION_USED_TOPIC:"0x98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a5"
keccak256("AuthorizationUsed(address,bytes32)")
DELEGATION_MANAGER
constDELEGATION_MANAGER:"0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3"
MetaMask's reference DelegationManager, v1.3.0, at one CREATE2 address.
DELEGATION_MANAGER_CHAINS
constDELEGATION_MANAGER_CHAINS: readonlynumber[]
The chain ids whose deployment record holds a DelegationManager at DELEGATION_MANAGER.
ESCROW
constESCROW: { readonly [d in "v1.1" | "v1.0"]: { chargedTopic: Hex; eip3009Collector: Hex; escrow: Hex; permit2Collector: Hex } }
The commerce-payments escrow's two deployments: the escrow, its two token collectors, and PaymentCharged's topic.
EXACT_PERMIT2_PROXY
constEXACT_PERMIT2_PROXY:"0x402085c248EeA27D92E8b30b2C58ed07f9E20001"
PAYMENT_AUTHORIZED_TOPIC
constPAYMENT_AUTHORIZED_TOPIC:"0x1c81fb2e3bab27f6bb09bee9a0dddf61600b7cbaf2c12683e4864e0cbdb9d284"
PAYMENT_INFO_TYPEHASH
constPAYMENT_INFO_TYPEHASH:"0xae68ac7ce30c86ece8196b61a7c486d8f0061f575037fbd34e7fe4e2820c6591"
PERMIT2
constPERMIT2:"0x000000000022D473030F116dDEE9F6B43aC78BA3"
RECEIVE_POLICY_GUARD
constRECEIVE_POLICY_GUARD:"0xb10c000000000000000000000000000000000000"
Where a Tempo receive policy sends a blocked transfer.
REDEEMED_DELEGATION_TOPIC
constREDEEMED_DELEGATION_TOPIC:"0x40dadaa36c6c2e3d7317e24757451ffb2d603d875f0ad5e92c5dd156573b1873"
SALT_BINDING_TYPEHASH
constSALT_BINDING_TYPEHASH:"0x8a2a7e41a0bda000ded071ff38b79401d2603e1826516ff2635b11fe9e30877f"
TRANSFER_TOPIC
constTRANSFER_TOPIC:"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
keccak256("Transfer(address,address,uint256)")
TRANSFER_WITH_AUTHORIZATION_TYPEHASH
constTRANSFER_WITH_AUTHORIZATION_TYPEHASH:"0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267"
keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
UPTO_PERMIT2_PROXY
constUPTO_PERMIT2_PROXY:"0x4020A4f3b7b90ccA423B9fabCc0CE57C6C240002"
Functions
authorizationIdDigest()
authorizationIdDigest(
from,to,value):Promise<`0x${string}`|Refusal>
SHA-256 over the 72 bytes of abi.encodePacked(address from, address to, uint256 value): the identity of one
transfer, which a Transfer(from, to, value) log in the settlement transaction reproduces.
Parameters
| Parameter | Type |
|---|---|
from | `0x${string}` |
to | `0x${string}` |
value | string | bigint |
Returns
Promise<`0x${string}` | Refusal>
bindSalt()
bindSalt(
receiverAuthorizer,policy,h):`0x${string}`|Refusal
keccak256(abi.encode(SALT_BINDING_TYPEHASH, receiverAuthorizer, policy, h)).
Parameters
| Parameter | Type |
|---|---|
receiverAuthorizer | `0x${string}` |
policy | `0x${string}` |
h | `0x${string}` |
Returns
`0x${string}` | Refusal
carriesBinding()
carriesBinding(
log,b):boolean
A log from address whose topic index, or data word dataWord, equals value by bytes, under topic0.
Parameters
| Parameter | Type |
|---|---|
log | EvmLog |
b | NonNullable<{ address: `0x${string}`; topic0: `0x${string}`; value: `0x${string}`; } & ({ index: 2 | 1 | 3; } | { dataWord: number; }) | undefined> |
Returns
boolean
decodePermissionContext()
decodePermissionContext(
ctx):Refusal|Delegation[]
Decodes abi.encode(Delegation[]), strictly: every offset and length lies inside the input and is 32-byte aligned,
address words carry 12 zero bytes, and there are at most 8 delegations, 16 caveats each, and 8 KiB per bytes. The
array is returned in the input's order, leaf first. An empty array decodes to [].
Parameters
| Parameter | Type |
|---|---|
ctx | `0x${string}` |
Returns
Refusal | Delegation[]
eip3009Recover()
eip3009Recover(
ref,reader):Promise<`0x${string}`|Refusal>
Recovers the hash from a settlement transaction alone: the one distinct nonce among the AuthorizationUsed logs
that asset emitted in it. One call.
Parameters
Returns
Promise<`0x${string}` | Refusal>
eip3009Status()
eip3009Status(
ref,reader):Promise<EvmStatus>
Reads the named transaction. Settled when its receipt succeeded and holds a log from asset with exactly three
topics, the first AuthorizationUsed and the third equal to h; the finality is the highest block mark at or above
the receipt's block. A failed read, or a reader for another network, is pending, never failed. At most three calls.
Parameters
Returns
Promise<EvmStatus>
eip3009TypedData()
eip3009TypedData(
a):Refusal|Eip3009TypedData
The EIP-712 typed data for TransferWithAuthorization, with the field lists in ERC-3009's order. The domain's
verifyingContract is the token.
Parameters
| Parameter | Type |
|---|---|
a | { asset: `0x${string}`; from: `0x${string}`; name: string; network: `eip155:${string}`; nonce: `0x${string}`; to: `0x${string}`; validAfter: bigint; validBefore: bigint; value: string; version: string; } |
a.asset | `0x${string}` |
a.from | `0x${string}` |
a.name | string |
a.network | `eip155:${string}` |
a.nonce | `0x${string}` |
a.to | `0x${string}` |
a.validAfter | bigint |
a.validBefore | bigint |
a.value | string |
a.version | string |
Returns
evmStatus()
evmStatus(
ref,reader):Promise<EvmBreadthStatus>
Reads the named transaction. A reader for another network, or a failed read, is pending; no receipt is pending
not-found; a revert is failed. On success each log the ref names must be present, emitted by the named contract:
the binding log with value in its topic or data word, and the transfer log whose from, to and value hash to
the digest. Settled carries the highest finality mark reached. At most three calls.
Parameters
Returns
Promise<EvmBreadthStatus>
isLog()
isLog(
l):l is EvmLog
True for a log with a string address, string topics and string data.
Parameters
| Parameter | Type |
|---|---|
l | unknown |
Returns
l is EvmLog
isReceipt()
isReceipt(
r):r is EvmReceipt
True for a receipt with a 0 or 1 status, a bigint block number and a list of logs.
Parameters
| Parameter | Type |
|---|---|
r | unknown |
Returns
r is EvmReceipt
paymentHash()
paymentHash(
chainId,escrow,p):`0x${string}`|Refusal
The escrow's getHash: keccak256(abi.encode(chainId, escrow, keccak256(abi.encode(PAYMENT_INFO_TYPEHASH, p)))).
With payer zero it is x402's signatureNonce.
Parameters
| Parameter | Type |
|---|---|
chainId | number |
escrow | `0x${string}` |
p | PaymentInfo |
Returns
`0x${string}` | Refusal
permit2TypedData()
permit2TypedData(
a):Refusal|Permit2TypedData
Permit2's typed data under its domain (name "Permit2", no version). No witness gives PermitTransferFrom; a
witness gives PermitWitnessTransferFrom, or PermitBatchWitnessTransferFrom when permitted is an array.
Parameters
| Parameter | Type |
|---|---|
a | { chainId: number; deadline: bigint; nonce: bigint; permitted: { amount: bigint; token: `0x${string}`; } | readonly object[]; spender: `0x${string}`; verifyingContract?: `0x${string}`; witness?: { fields: readonly Field[]; type: string; value: {[k: string]: Json; }; }; } |
a.chainId | number |
a.deadline | bigint |
a.nonce | bigint |
a.permitted | { amount: bigint; token: `0x${string}`; } | readonly object[] |
a.spender | `0x${string}` |
a.verifyingContract? | `0x${string}` |
a.witness? | { fields: readonly Field[]; type: string; value: {[k: string]: Json; }; } |
a.witness.fields | readonly Field[] |
a.witness.type | string |
a.witness.value | {[k: string]: Json; } |
Returns
receiveTypedData()
receiveTypedData(
a):Refusal|ReceiveTypedData
The EIP-712 typed data for ReceiveWithAuthorization, built as eip3009TypedData builds its transfer form.
Parameters
| Parameter | Type |
|---|---|
a | { asset: `0x${string}`; from: `0x${string}`; name: string; network: `eip155:${string}`; nonce: `0x${string}`; to: `0x${string}`; validAfter: bigint; validBefore: bigint; value: string; version: string; } |
a.asset | `0x${string}` |
a.from | `0x${string}` |
a.name | string |
a.network | `eip155:${string}` |
a.nonce | `0x${string}` |
a.to | `0x${string}` |
a.validAfter | bigint |
a.validBefore | bigint |
a.value | string |
a.version | string |
Returns
redeemedLeafRecover()
redeemedLeafRecover(
ref,reader):Promise<`0x${string}`|Refusal>
Recovers H from a settlement transaction through MetaMask's DelegationManager: among its RedeemedDelegation logs,
the leaves are those whose data word 1 (the delegate) is the redeemer in topic 2 or the wildcard delegate; exactly
one distinct leaf salt (data word 5) is H. One call.
Parameters
| Parameter | Type |
|---|---|
ref | { network: `eip155:${string}`; transaction: `0x${string}`; } |
ref.network | `eip155:${string}` |
ref.transaction | `0x${string}` |
reader | EvmReader |
Returns
Promise<`0x${string}` | Refusal>
settledAt()
settledAt(
at,reader):Promise<EvmStatus&object>
Settled at the highest finality mark whose block is at or above at; a failed mark read counts as not reached.
Parameters
| Parameter | Type |
|---|---|
at | bigint |
reader | EvmReader |
Returns
Promise<EvmStatus & object>
transferDigest()
transferDigest(
v):Promise<`0x${string}`|Refusal>
the core's hash over the fields present, in the order from, to, value: 20, 20 and 32 bytes, the value as a
big-endian uint256. authorizationIdDigest(from, to, value) equals transferDigest({from, to, value}).
Parameters
| Parameter | Type |
|---|---|
v | { from?: `0x${string}`; to?: `0x${string}`; value?: bigint; } |
v.from? | `0x${string}` |
v.to? | `0x${string}` |
v.value? | bigint |
Returns
Promise<`0x${string}` | Refusal>
transferParts()
transferParts(
log,address,topic0): {from:`0x${string}`;to:`0x${string}`;value:bigint; } |undefined
from and to from topics 1 and 2 (their low 20 bytes) and value from data word 0, for a log from address
under topic0. An ERC-20 Transfer has exactly three topics; an event that also indexes a memo has four.
Parameters
| Parameter | Type |
|---|---|
log | EvmLog |
address | `0x${string}` |
topic0 | `0x${string}` |
Returns
{ from: `0x${string}`; to: `0x${string}`; value: bigint; } | undefined
Last updated on