From 9720b065636bbd67c45c3eb7c456ebc88e8ff48f Mon Sep 17 00:00:00 2001
From: darwintree <17946284+darwintree@users.noreply.github.com>
Date: Thu, 7 Mar 2024 18:23:45 +0800
Subject: [PATCH] docs: add explanation for how to encode function data
---
.../pages/API/Catalogue/Function/SendTransaction.tsx | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/examples/docs/src/pages/API/Catalogue/Function/SendTransaction.tsx b/examples/docs/src/pages/API/Catalogue/Function/SendTransaction.tsx
index 456193c..05d7d51 100644
--- a/examples/docs/src/pages/API/Catalogue/Function/SendTransaction.tsx
+++ b/examples/docs/src/pages/API/Catalogue/Function/SendTransaction.tsx
@@ -7,14 +7,16 @@ const transitions = {
en: {
step1: `The sendTransaction
function return a Promise. Calling sendTransaction
when the status is 'active'
will raise the wallet to issue a transaction based on the input parameters. If it is not called when 'active'
, Promise will be rejected.`,
step2: `Unlike transactions initiated via RPC, sendTransaction
only requires three parameters: to
, value
, and data
(if any), and the from
parameter is built into the current account.`,
- step3: `The value
should be a hexadecimal string starting with '0x', indicating the smallest unit of the corresponding currency ('drip' in conflux | 'wei' in ethereum). 'Undefined' value
is equivalent to filling in '0x0'.`,
- step4: `A successful transaction will resolve hash-string
, a failed transaction will reject.`,
+ step3: `The data
field can remain vacant. However, if populated, it should be a hexadecimal string. This string is key for either deploying a contract or declaring the specific contract methods and parameters to be invoked. In cases where a contract method is invoked, it's crucial to convert the called method and associated parameters into a 16-digit hexadecimal string, which will serve as the data
. This encoding process can be understood better through these guides: js-conflux-sdk(get contract method data), web3.js(encodeFunctionCall), ethers.js(encodeFunctionData), viem(encodeFunctionData).`,
+ step4: `The value
should be a hexadecimal string starting with '0x', indicating the smallest unit of the corresponding currency ('drip' in conflux | 'wei' in ethereum). 'Undefined' value
is equivalent to filling in '0x0'.`,
+ step5: `A successful transaction will resolve hash-string
, a failed transaction will reject.`,
},
zh: {
step1: `sendTransaction
函数返回一个 Promise。在 status 为 'active'
时调用 sendTransaction
,会根据入参调起钱包签发一笔交易。如果不在 'active'
时调用,Promise 会直接 reject。`,
step2: `不同于通过 RPC 发起的交易,sendTransaction
只需要填 to
、value
、data
(如果有) 这三个参数,from
参数内置为当前账户。`,
- step3: `value
应该为 '0x' 开头的 16 进制数字字符串,表示对应货币的最小单位('drip' in conflux | 'wei' in ethereum)。不填 value
等效于填 '0x0'。`,
- step4: `成功交易会 resolve hash-string
,失败则 reject。`,
+ step3: `data
字段可为空。不为空时,该字段为编码后的 16 进制数字字符串串,用于部署合约或声明调用的合约方法与参数。调用合约方法时,需要将调用的方法与参数编码为 16 进制串,作为 data
。编码方法请参考 js-conflux-sdk(get contract method data), web3.js(encodeFunctionCall), ethers.js(encodeFunctionData), viem(encodeFunctionData)。`,
+ step4: `value
应该为 '0x' 开头的 16 进制数字字符串,表示对应货币的最小单位('drip' in conflux | 'wei' in ethereum)。不填 value
等效于填 '0x0'。`,
+ step5: `成功交易会 resolve hash-string
,失败则 reject。`,
},
} as const;
@@ -58,6 +60,7 @@ const handleSendTransaction = async() => {