Transaction Format
A Kairos transaction, or fastBid, is a single hexadecimal encoded transaction (see Relay JSON-RPC API for more information)
Example:
// Check next doc page of `submitFastBid`
// for ethers implementation instead
const Web3 = require('web3');
var web3 = new Web3(
'https://matic-mainnet.infura.io/v3/some_random_hash_provider'
);
const PRIVATE_KEY = '0xsomePrivateKey';
const functionCall = {
inputs: [
{
internalType: 'uint256',
name: 'fastGasPrice',
type: 'uint256'
},
{
internalType: 'address',
name: 'searcherToAddress',
type: 'address'
},
{
internalType: 'bytes',
name: 'searcherCallData',
type: 'bytes'
}
],
name: 'submitFastBid',
outputs: [],
stateMutability: 'payable',
type: 'function'
};
const fastGasPrice = 10 * 1e9; // 10 gwei
const searcherContract = '0xeA26974363EC1dBc132C99cF9A29273B17254aE3';
// Assuming we intend to use _searcherCallDataBytes
// when received on our searcher contract `fastLaneCall(` callback
// to then trigger searcherContract.myMethod(uint256,string);
// See: Searcher Call Data section of the docs for more informations
const searcherCallDataBytes = web3.eth.abi.encodeFunctionCall(
{
name: 'myMethod',
type: 'function',
inputs: [
{
type: 'uint256',
name: 'myNumber'
},
{
type: 'string',
name: 'myString'
}
]
},
['2345675643', 'Hello!%']
);
const dataField = web3.eth.abi.encodeFunctionCall(functionCall, [
fastGasPrice,
searcherContract,
searcherCallDataBytes
]);
// Gas must match
const transaction = {
to: '0xf5df545113dee4df10f8149090aa737ddc05070a', // Auction Handler Beta
nonce: 12,
data: dataField
};
async function main() {
const signedTx = await web3.eth.accounts.signTransaction(
transaction,
PRIVATE_KEY
);
console.log(signedTx.rawTransaction); // 0xf901b20c8502e155e78c8275309431b98d14007bdee637298086988a0bbd...1baddd8f2f8f940fc5d387832a1
return signedTx.rawTransaction;
}
main();
More details in
from web3 import Web3
signed_encoded_tx = signed_tx.rawTransaction.hex()
Last updated