Revelium.Evm
0.0.1
dotnet add package Revelium.Evm --version 0.0.1
NuGet\Install-Package Revelium.Evm -Version 0.0.1
<PackageReference Include="Revelium.Evm" Version="0.0.1" />
paket add Revelium.Evm --version 0.0.1
#r "nuget: Revelium.Evm, 0.0.1"
// Install Revelium.Evm as a Cake Addin #addin nuget:?package=Revelium.Evm&version=0.0.1 // Install Revelium.Evm as a Cake Tool #tool nuget:?package=Revelium.Evm&version=0.0.1
Revelium.Evm
Revelium.Evm is .NET standard 2.1 integration library for EVM-compatible networks.
Getting started
Installation
PM> Install-Package Revelium.Evm
Create, sign and send transaction (long way)
Let's create new wallet and signer:
var key = EthECKey.GenerateKey();
var signer = new EthEcdsaSigner(key);
var fromAddress = signer.GetAddress();
To interact with the Etherlink test network, let's create an rpc client:
var rpc = new RpcClient(url: RpcClient.ETHERLINK_TESTNET);
Now we need a transaction counter for the nonce. To do this, we will use the nonce manager, which allows you to send transactions without waiting for confirmation of previous ones:
var (nonce, nonceError) = await NonceManager.Instance.GetNonceAsync(
rpc: rpc,
address: fromAddress,
pending: true);
if (nonceError != null) { /* do something if necessary */ }
Let's create an Approve transaction for the Erc20 token:
var approve = new Approve
{
FromAddress = fromAddress,
GasPrice = 100_000_000,
Gas = 1_000_000,
Nonce = nonce,
Spender = "<SPENDER_ADDRESS>",
Value = 1_000_000_000_000
}.CreateTransactionInput("<TOKEN_CONTRACT_ADDRESS>");
We can also estimate gas usage:
var (estimatedGas, estimateGasError) = await rpc.EstimateGasAsync(
block: BlockNumber.Latest,
to: approve.To,
from: approve.From,
gasPrice: approve.GasPrice,
value: 0,
data: approve.Data);
if (estimateGasError == null)
approve.Gas = new HexBigInteger(estimatedGas);
Everything is ready to sign the transaction, verify and send:
var request = new TransactionLegacyRequest(approve);
signer.Sign(request);
if (!request.Verify()) { /* do something if necessary */ }
var (txId, error) = await rpc.SendRawTransactionAsync(request);
And at the end we will receive the sent transaction via the BlockScout API:
var api = new BlockScoutApi(BlockScoutApi.ETHERLINK_TESTNET);
var tx = await api.GetTransactionAsync(txId);
Create, sign and send transaction (short way)
The same thing can be done in a shorter way using a helper method:
var tx = new TransactionLegacyRequest
{
From = fromAddress,
To = "<TOKEN_CONTRACT_ADDRESS>",
GasPrice = 100_000_000,
Data = new Approve
{
Spender = "<SPENDER_ADDRESS>",
Value = 1_000_000_000_000
}.CreateTransactionInput("<TOKEN_CONTRACT_ADDRESS>").Data
};
var (txId, error) = await rpc.SignAndSendLegacyTransactionAsync(
tx: tx,
signer: signer,
estimateGas: true,
cancellationToken: cancellationToken);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Incendium.Result (>= 1.0.4)
- Incendium.RetryPolicy (>= 1.0.2)
- Nethereum.Contracts (>= 4.26.0)
- Nethereum.Signer (>= 4.26.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Text.Json (>= 8.0.5)
- System.Threading.Channels (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Revelium.Evm:
Package | Downloads |
---|---|
Hanji.Sdk
Hanji.Sdk is .NET integration library for Hanji platform |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 93 | 11/13/2024 |