sendEvmTx() to send it on behalf of the seed.
sendEvmTx(tx, baseUrl, seed)
| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| tx | EvmTransaction | Required | N/A | EVM compatible transaction object returned from an SDK method. Send it manually with ethers.js or web3.js, or pass it to sendEvmTx(). |
| baseUrl | string | Required | N/A | RPC url used to connect to the blockchain. Reference Connecting to peaq for supported RPC urls. |
| seed | string | Required | N/A | Ethereum private key linked to the wallet executing the transactions. Allows the backend to perform write transactions on behalf of the user. |
import { Sdk } from "@peaq-network/sdk";
const HTTPS_BASE_URL = "https://quicknode1.peaq.xyz";
const EVM_PRIVATE = process.env['EVM_PRIVATE'];
const sdk = await Sdk.createInstance({
baseUrl: HTTPS_BASE_URL,
chainType: Sdk.ChainType.EVM
});
// e.g. sdk.did.create(), sdk.did.update(), sdk.storage.addItem() ... etc.
// all return back a valid EVM tx that is used in sendEvmTx()
const tx = await sdk.storage.addItem({
itemType: "my_key",
item: "my_value"
});
const receipt = await Sdk.sendEvmTx({
tx: tx,
baseUrl: HTTPS_BASE_URL,
seed: EVM_PRIVATE
});
// receipt object of the EVM transaction for the storage addItem call
TransactionReceipt {
provider: JsonRpcProvider {},
to: '0x0000000000000000000000000000000000000801',
from: '0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C',
contractAddress: null,
hash: '0x2eebdc26f2997cf1908bc742c8567ef607498880e5e603012836fcede9a481f3',
index: 0,
blockHash: '0x857356cffe490f429900d550b3f5fec7c3874c7de53c149116e834c4cc43d5dc',
blockNumber: 2621813,
logsBloom: '0x00000040000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
gasUsed: 48090n,
blobGasUsed: null,
cumulativeGasUsed: 48090n,
gasPrice: 1024n,
blobGasPrice: null,
type: 2,
status: 1,
root: undefined
}

