尝试发送RPC请求时发生错误

发布于 2025-02-08 11:48:48 字数 1329 浏览 0 评论 0原文

我想签名然后进行sendtracsaction,

var mintMsg = new TransferFunction()
        {
            TokenAmount = 1,
            To = "0x6f78e96E4cDeca2F1e121f23Bc2effBaaea05E8f",
            Nonce = 57,
            GasPrice = 5,
            Gas = 70000
        };
        var txHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
        var signedTx = await txHandler.SignTransactionAsync(contractAddress, mintMsg);

        // Attempt #1
        var txReceipt = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync(signedTx);
        // Attempt #2
        TransactionInput transactionInput = new TransactionInput()
            {
                ChainId = new HexBigInteger(Web3.Convert.ToWei(56, UnitConversion.EthUnit.Wei)),
                Gas = new HexBigInteger(Web3.Convert.ToWei(70000, UnitConversion.EthUnit.Wei)),
                GasPrice = new HexBigInteger(Web3.Convert.ToWei(5, UnitConversion.EthUnit.Wei)),
                Nonce = new HexBigInteger(await GetTransactionCount()),
                To = "0x6f78e96E4cDeca2F1e121f23Bc2effBaaea05E8f",
                Data = signedTx,
                Value = new HexBigInteger(100),

            };
        var txReceipt2 = await web3.Eth.Transactions.SendTransaction.SendRequestAsync(transactionInput);

这是不起作用的。

I want to SignContract and then SendTracsaction,

var mintMsg = new TransferFunction()
        {
            TokenAmount = 1,
            To = "0x6f78e96E4cDeca2F1e121f23Bc2effBaaea05E8f",
            Nonce = 57,
            GasPrice = 5,
            Gas = 70000
        };
        var txHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
        var signedTx = await txHandler.SignTransactionAsync(contractAddress, mintMsg);

        // Attempt #1
        var txReceipt = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync(signedTx);
        // Attempt #2
        TransactionInput transactionInput = new TransactionInput()
            {
                ChainId = new HexBigInteger(Web3.Convert.ToWei(56, UnitConversion.EthUnit.Wei)),
                Gas = new HexBigInteger(Web3.Convert.ToWei(70000, UnitConversion.EthUnit.Wei)),
                GasPrice = new HexBigInteger(Web3.Convert.ToWei(5, UnitConversion.EthUnit.Wei)),
                Nonce = new HexBigInteger(await GetTransactionCount()),
                To = "0x6f78e96E4cDeca2F1e121f23Bc2effBaaea05E8f",
                Data = signedTx,
                Value = new HexBigInteger(100),

            };
        var txReceipt2 = await web3.Eth.Transactions.SendTransaction.SendRequestAsync(transactionInput);

This is not working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清醇 2025-02-15 11:48:48

我也有同样的问题,此代码对我有用

var privateKey = _user.PrivateKey;
var account = new Account(privateKey);
var web3 = new Web3(account, "https://bsc-dataseed.binance.org/");

I have the same issue, and this code working for me

var privateKey = _user.PrivateKey;
var account = new Account(privateKey);
var web3 = new Web3(account, "https://bsc-dataseed.binance.org/");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文