⚡ MultiversX SmartSend .NET SDK: Library for interacting with Smart Send contracts on MultiversX blockchain
The content is delivered via nuget packages:
- Create EGLD/Token/MetaESDT/NFT/SFT transactions for Smart Send contracts
IApiProvider provider = new ApiProvider(new ApiNetworkConfiguration(Network.DevNet));
var networkConfig = await NetworkConfig.GetFromNetwork(provider);
var account = Account.From(await provider.GetAccount("MY_ADDRESS"));
var mySmartSendContractAddress = "MY_CONTRACT_ADDRESS";
var smartSend = new SmartSend(account, networkConfig, mySmartSendContractAddress);
var inputTransactions = new List<TokenAmount>()
{
new TokenAmount("ADDRESS_1", 0.1m, ESDT.EGLD()),
new TokenAmount("ADDRESS_2", 0.03m, ESDT.EGLD())
};
var egldTxs = smartSend.CreateEGLDTransactions(inputTransactions);
//sign and send egldTxs
The following example is using a wallet signer that should not be used in production, only in private!
IApiProvider provider = new ApiProvider(new ApiNetworkConfiguration(Network.DevNet));
var networkConfig = await NetworkConfig.GetFromNetwork(provider);
var filePath = "PATH/TO/KEYFILE.json";
var password = "PASSWORD";
var signer = Signer.FromKeyFile(filePath, password);
var account = Account.From(await provider.GetAccount(signer.GetAddress().Bech32));
var mySmartSendContractAddress = "MY_CONTRACT_ADDRESS";
var smartSend = new SmartSend(account, networkConfig, mySmartSendContractAddress);
var inputTransactions = new List<TokenAmount>()
{
new TokenAmount("ADDRESS_1", 0.1m, ESDT.EGLD()),
new TokenAmount("ADDRESS_2", 0.03m, ESDT.EGLD())
};
var egldTxs = smartSend.CreateEGLDTransactions(inputTransactions);
var signed = egldTxs.MultiSign(signer);
var response = await provider.SendTransactions(signed);
foreach (var hash in response.TxsHashes)
Console.WriteLine(hash.Value);