当你完成了上述的操作后,这时候可以尝试发起一笔交易。调用 POST /api/v5/waas/wallet/pre-transaction/sign-info
接口,查询签名所需要的一些数据,包含 EVM 链相关的 gas price、gas limit、nonce 等。
//定义你的参数
// EVM
const postSignInfoBody = {
chainIndex: '1',
fromAddr: '0xdf54b6c6195ea4d948d03bfd818d365cf175cfc2',
toAddr: '0x1e80c39051f078ee34763282cbb36ffd88b40c65',
txAmount: '123000000000000',
extJson: {
inputData: '041bbc6fa102394773c6d8f6d634320773af4'
}
};
// UTXO
/*
const getSignInfoBody = {
fromAddr: 'bc1psnr548clz3f4fz6jmpnw5eqzj2v2musk082wp8fvq5ac3p5ete6qg05u8u',
toAddr: 'bc1psnr548clz3f4fz6jmpnw5eqzj2v2musk082wp8fvq5ac3p5ete6qg05u8u',
txAmount: '123000000000000',
chainId: '0',
extJson: {}
};
*/
//定义辅助函数
const signInfoData = async () => {
const apiRequestUrl = getRequestUrl(
apiBaseUrl,
'/api/v5/waas/wallet/pre-transaction/sign-info'
);
return fetch(apiRequestUrl, {
method: 'post',
headers: headersParams,
body: JSON.stringify(postSignInfoBody),
})
.then((res) => res.json())
.then((res) => {
return res;
});
};
const { data: signInfoData } = await signInfoData();
当查询到相关信息后,你将收到如下的响应:
// EVM
{
"code": 0,
"msg": "success",
"data": [
// EVM
{
"gasLimit": "21000",
"nonce": "0",
"gasPrice": {
"normal": "12200500000",
"min": "9130000000",
"max": "16801000000",
"supportEip1559": true,
"erc1599Protocol": {
"suggestBaseFee": "8630000000",
"proposePriorityFee": "550000000",
"safePriorityFee": "500000000",
"fastPriorityFee": "2130000000",
"baseFee": "8630000000"
}
}
},
]
}