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);
I try research internet but not working. I would like to thank anyone who made the effort to reply.
CodePudding user response:
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/");