transactionsnethereum

Is there a class Nethereum.Signer.Transaction?


I want to make a program to interact with EVM compatible blockchain.

The plan is to use nethereum for most offline parts, like signing, encoding, decoding, etc, and then use normal webclient for the transaction.

This keeps things simple because I already have a webclient library.

I asked ChatGPT how to do so and I got this code

Dim rawTransaction = New Transaction(
    destination,
    New HexBigInteger(transferAmountInWei), ' Value in Wei
    New HexBigInteger(nonce), ' Nonce
    New HexBigInteger(gasPrice), ' Gas Price
    New HexBigInteger(gasLimit), ' Gas Limit
    Nothing ' No data for simple transfer
)

' Sign the transaction
Dim signer As New TransactionSigner()
Dim signedTransaction As String = signer.SignTransaction(privateKey, rawTransaction)

That code doesn't work. It says no Transaction constructor take that argument.

I wonder if I am dealing with different Transaction class. So I asked chatgpt the full name of Transaction

The Transaction class in Nethereum for creating raw transactions is fully qualified as:

Nethereum.Signer.Transaction

If you don't use Imports, you should use the fully qualified name when creating the transaction:

vb Copy code

Dim rawTransaction = New Nethereum.Signer.Transaction()

There is no such thing.

Clicking on definition of Transaction class show that it's on namespace

Also Dim rawTransaction = New Transaction( destination, New HexBigInteger(transferAmountInWei), ' Value in Wei New HexBigInteger(nonce), ' Nonce New HexBigInteger(gasPrice), ' Gas Price New HexBigInteger(gasLimit), ' Gas Limit Nothing ' No data for simple transfer )

Doesn't work.

What works is

    Dim rawTransaction = New Nethereum.RPC.Eth.DTOs.Transaction()
    rawTransaction.To = destination
    rawTransaction.Value = New HexBigInteger(transferAmountInWei)
    rawTransaction.Nonce = New HexBigInteger(nonce)
    rawTransaction.GasPrice = New HexBigInteger(gasPrice)
    rawTransaction.Gas = New HexBigInteger(gasLimit)

The thing is gemini confirms chatgpt

is there a class Nethereum.Signer.Transaction

Yes, there is a Transaction class within the Nethereum.Signer namespace.

Key Points:

Purpose: This class represents an Ethereum transaction, encapsulating information like sender, recipient, gas limit, gas price, and more. Usage: It's typically used for: Creating and configuring transactions before signing them. Signing transactions using private keys. Preparing transactions for sending to the Ethereum network. Finding the Class:

Source Code: You can find the Transaction class within the source code of the Nethereum library. Note:

The Transaction class in Nethereum.Signer might differ slightly in its properties and methods compared to the Transaction class used for sending transactions directly to the Ethereum network via the Web3 client. I hope this clarifies the existence and purpose of the Transaction class in the Nethereum.Signer namespace.

How many classes called Transaction is on Nethereum? And where can I see that?

Also reinstalling nuget or whatever still don't show Nethereum.Signer.Transaction

Yet both chatgpt and gemini insist there is.


Solution

  • It seems that both ChatGPT and Gemini insist those class exist.

    The class have changed name to LegacyTransaction

    Looks like Nethereum changes a lot and different version is not compatible with older version.