我正在寻找合同互动的原始JSON /正文 < / strong> < / strong>它已签署并传递给Web3py / web3js / ethers,
我们正在使用AWS KMS进行钱包设置。这个钱包应该采取一些自动操作。我面临的问题是,为了创建签名,该操作必须以原始格式传递给kms。
我找到了“ nofollow noreferrer”>教程和样本(以太坊本身)从KMS钱包到收件人,所描述的过程是创建一个包含所有必需信息的原始dict,用给定的KMS方法签名,然后将其作为原始事务发布。
例如,简单的交易原始dict应该看起来像这样(EIP-1559之后),
{
'nonce': nonce,
'to': 0x0131c121,
'value': 1000000000000,
'data': '0x00',
'gas': 160000,
'maxFeePerGas': max_fee_per_gas,
'maxPriorityFeePerGas': max_priority_fee_per_gas,
'type': type,
'chainId': chainid,
}
我们试图做的是与需要根据用户操作进行一些更改的各种合同进行交互。我认为应该工作的方式是弄清楚给定合同互动的字典组件的外观。如果有人可以将我指向正确的方向或解释合同互动的原始JSON/身体的样子,那就太好了
I'm looking for an example of a raw json/body of a contract interaction before it is signed and passed to web3py / web3js / ethers
We are using AWS KMS for our wallet setup. There are some automated actions that this wallet is supposed to take. The problem I am facing is that in order to create a signature, the action has to be passed to KMS in a raw format.
I have found tutorials and samples describing the process to transfer a native token (ethereum itself) from the KMS wallet to a recipient, the process described is to create a raw dict containing all the required info, sign it with a given KMS method and then post it as a raw transaction.
For example a simple transaction raw dict should look like this (post EIP-1559)
{
'nonce': nonce,
'to': 0x0131c121,
'value': 1000000000000,
'data': '0x00',
'gas': 160000,
'maxFeePerGas': max_fee_per_gas,
'maxPriorityFeePerGas': max_priority_fee_per_gas,
'type': type,
'chainId': chainid,
}
What we are trying to do, however, is to interact with various contracts that require some changes based on user actions. The way that I believe should work is to figure out what the dictionary body components look like for a given contract interaction. It would be great if someone could point me into the right direction or explain what the raw json/body of a contract interaction looks like
发布评论
评论(1)
实际上比我想象的要简单得多。
data
字段是描述与给定收件人地址(合同)相互作用的原因,并且如以下规格https://docs.soliditylang.org/en/latest/abi-spec.html#formal-specification-编码
长话短说,
我只是在web3py上使用了
buildtransaction
函数用给定ABI构建原始事务,因为USDC是合同的实例。
Actually a lot simpler than I thought.
The
data
field is what describes the interaction with a given recipient address (which is the contract) and works as described in the following specshttps://docs.soliditylang.org/en/latest/abi-spec.html#formal-specification-of-the-encoding
Long story short,
I just used the
buildTransaction
function on web3py to build a raw transaction with the given abi as suchwhere usdc is an instance of the contract.