> For the complete documentation index, see [llms.txt](https://docs-sdk.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-sdk.crypto-chief.com/processing/dotnet/guides/contract-calls.md).

# Contract calls (EVM / TRON)

Call EVM, TRON, and Solana contracts in .NET / C# without hand-encoding calldata.

Most real-world transactions are smart-contract calls. You never encode the `data` field by hand: give the SDK a typed description and get back a signed reservation.

{% hint style="warning" %}
Contract-type transactions (`SignEvmCallAsync`, `Erc20TransferAsync`, `SignTronCallAsync`, `SignAnchorCallAsync` — every helper in this guide signs `type=contract`) are covered by the same [execute-time pre-flight](/processing/dotnet/guides/sign-execute.md): a wallet without enough native coin for gas gets `PREFLIGHT_FAILED` instead of an on-chain revert or a silent gas burn. On TRON, the call is additionally simulated, so a reverting call (including an insufficient token balance) is rejected as `simulation_reverted` before any fee is spent.
{% endhint %}

## EVM — by Solidity signature

{% hint style="danger" %}
This snippet shows the **encoder**, not a complete swap. Two things have to be true before a swap like this succeeds on chain:

* **An allowance.** Uniswap's router moves your input token with `transferFrom`, so it needs an ERC-20 `approve(address,uint256)` on that token first, confirmed before the swap is signed — the nonce comes from chain state. Without it the swap reverts and burns the gas.
* **A slippage floor.** `amountOutMin` of `0` accepts whatever the pool returns, which on a public mempool hands the trade to the first sandwich bot that sees it. Pass a real minimum, in the output token's base units.
  {% endhint %}

```csharp
using System.Numerics;
using CryptoChief.Processing.Amounts;
using CryptoChief.Processing.Chains;
using CryptoChief.Processing.Services;

var amountIn     = Amount.HumanToBase("0.01", 18);
var amountOutMin = BigInteger.Zero;
var deadline     = new BigInteger(DateTimeOffset.UtcNow.AddMinutes(10).ToUnixTimeSeconds());
var path         = new[] { tokenIn, tokenOut };

var signed = await client.Transactions.SignEvmCallAsync(new EvmCallRequest
{
    Network     = Chain.EthMainnet,
    FromAddress = "0xYourWallet...",
    Contract    = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", // Uniswap V2 router
    Method      = "swapExactTokensForTokens(uint256,uint256,address[],address,uint256)",
    Args        = new object?[] { amountIn, amountOutMin, path, "0xYou...", deadline },
    UrlCallback = "https://your.app/webhooks/transaction",
});
```

The encoder supports `uint/int<M>`, `address`, `bool`, `bytes`, `bytes<N>`, `string`, and fixed/dynamic arrays of those. Argument values accept `BigInteger`, plain `int` / `long` / `uint` / `ulong`, decimal / hex strings, `byte[]`, and `IEnumerable<T>` of those.

## ERC-20 / TRC-20 transfer (one-liner)

```csharp
var amount = Amount.HumanToBase("12.5", 6); // USDT has 6 decimals

await client.Transactions.Erc20TransferAsync(new Erc20TransferRequest
{
    Network       = Chain.EthMainnet,
    FromAddress   = "0xYourWallet...",
    TokenContract = "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    Recipient     = "0xRecipient...",
    Amount        = amount,
});
```

## TRON — same encoder, base58 addresses

`SignTronCallAsync` (an alias of `SignEvmCallAsync`) accepts both base58 (`T...`) and `0x41`-prefixed hex addresses:

```csharp
await client.Transactions.SignTronCallAsync(new EvmCallRequest
{
    Network     = Chain.TronMainnet,
    FromAddress = "TYourWallet...",
    Contract    = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // USDT TRC-20
    Method      = "transfer(address,uint256)",
    Args        = new object?[] { "TRecipient...", amount },
});
```

Need to convert addresses outside a call? `CryptoChief.Processing.Encoders.Tron.TronAddress.ToHex` / `TronAddress.FromHex` are public.

## Solana — Anchor program

```csharp
using CryptoChief.Processing.Encoders.Solana;
using CryptoChief.Processing.Models;

var signed = await client.Transactions.SignAnchorCallAsync(new AnchorCallRequest
{
    Network     = Chain.SolanaMainnet,
    FromAddress = "YourWallet...",
    Program     = "YourProgramId...",
    Method      = "initialize",
    Args = new[]
    {
        Borsh.U64(1_000_000),
        Borsh.String("hello"),
    },
    Accounts = new[]
    {
        new SolanaAccount { Pubkey = "YourWallet...", IsSigner = true, IsWritable = true },
    },
});
```

Borsh primitives: `Borsh.U8/U16/U32/U64/U128`, `Borsh.I8/I16/I32/I64`, `Borsh.Bool`, `Borsh.String`, `Borsh.Bytes`, `Borsh.FixedBytes`, `Borsh.Pubkey`, `Borsh.Option`, `Borsh.Vec`, `Borsh.Struct`. For non-Anchor programs pass raw instruction bytes with `SignSolanaCallAsync`.

For TON contracts, see [TON transfers](/processing/dotnet/guides/ton.md).
