Skip to content

IOTA-NET/IotaWallet.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

status

Continuous Integration Deploy to Github NuGet Deploy to NuGet.org

Introduction ๐Ÿ˜„

This wallet leverages IOTA's official wallet.rs bindings and ports it over to .Net.

Now .Net developers can have a chance trying out IOTA/Shimmer as well!

Installation from Nuget.org

[!] Note the following two packages must be installed explicitly, do not skip it. !!! ๐Ÿ˜ก

dotnet add package IotaWallet.Net.Domain --prerelease

Or download from here.

dotnet add package IotaWallet.Net --prerelease

Or download from here.

Architecture support ๐Ÿ˜

It currently supports Windows x64 and Linux x86_64.

Additional Instructions for Linux ๐Ÿ˜ฎ

After installing IotaWallet.Net.Domain, when you build using dotnet build, you would see a file libiota_wallet.so. This is the precompiled rust bindings. You need to add it to your lib path.

Example...

export LD_LIBRARY_PATH=""

Note that its the folder path, not the filepath.

Alternative Installation ๐Ÿ’ซ

You can download the nugets from the github repo itself. Look to your right under Packages.

Usage Example ๐Ÿƒ

Setting up your wallet and sending a command

static async Task Main(string[] args)
{
    	//Register all of the dependencies into a collection of services
	IServiceCollection services = new ServiceCollection().AddIotaWalletServices();

	//Install services to service provider which is used for dependency injection
	IServiceProvider serviceProvider = services.BuildServiceProvider();

	//Use serviceprovider to create a scope, which safely disposes of all services at end of scope
	using (IServiceScope scope = serviceProvider.CreateScope())
	{
		//Request IWallet service from service provider
		IWallet wallet = scope.ServiceProvider.GetRequiredService<IWallet>();

		//Build wallet using a fluent-style configuration api
		wallet = wallet
			.ConfigureWalletOptions()
				.SetCoinType(WalletOptions.TypeOfCoin.Shimmer)
				.SetStoragePath("./walletdb")
				.Then()
			.ConfigureClientOptions()
				.AddNodeUrl("https://api.testnet.shimmer.network")
				.SetFaucetUrl("https://faucet.testnet.shimmer.network")
				.IsFallbackToLocalPow()
				.IsLocalPow()
				.Then()
			.ConfigureSecretManagerOptions()
				.SetPassword("password")
				.SetSnapshotPath("./mystronghold")
				.Then()
			.Initialize();

		//Let's generate a Mnemonic
		GetNewMnemonicResponse getNewMnemonicResponse = await wallet.GetNewMnemonicAsync();
		Console.WriteLine($"GetNewMnemonicAsync: {getNewMnemonicResponse}");
		string newMnemonic = getNewMnemonicResponse.Payload;
		
		//Store into stronghold
		//Remember, Generation and storage of mnemonic only is needed to do done the first time!
		StoreMnemonicResponse storeMnemonicResponse = await wallet.StoreMnemonicAsync(newMnemonic);
		Console.WriteLine($"StoreMnemonicAsync: {storeMnemonicResponse}");

		//Let's create an accounts, with username "cookiemonster"
		(CreateAccountResponse createAccountResponse, IAccount? account) = await wallet.CreateAccountAsync("cookiemonster");
		Console.WriteLine($"CreateAccountAsync: {createAccountResponse}");

		if (account == null)
		{
			Console.WriteLine("There was a problem creating the account.");
			return;
		}
		
		//Lets generate 1 new address!
		GenerateAddressesResponse generateAddressesResponse = await account.GenerateAddressesAsync(numberOfAddresses: 1, NetworkType.Testnet);
		Console.WriteLine($"GenerateAddressesAsync: {generateAddressesResponse}");
		string? generatedAddress = generateAddressesResponse.Payload?.FirstOrDefault()?.Address;
			
		//Let's request some Shimmer from the faucet
		await account.RequestFromFaucetAsync(generatedAddress);
        
		//Let's Checkout our balance. We will sync the account, followed by checking the balance.
		//Sync the account with the tangle
		await account.SyncAccountAsync();
		//Retrieve balance
		GetBalanceResponse getBalanceResponse = await account.GetBalanceAsync();
		Console.WriteLine($"GetBalanceAsync: {getBalanceResponse}");
		
		//Great, now that we have some test shimmer tokens to send, send to me!
		//Let's send 1 shimmer, which is 1,000,000 Glow, followed by 2 shimmer, which is 2000000 glow, via a single transaction
                //The below creates 2 outputs to the receiver address and 1 more output for your balance.

                string receiverAddress = "rms1qp8rknypruss89dkqnnuedm87y7xmnmdj2tk3rrpcy3sw3ev52q0vzl42tr";

                SendAmountResponse sendAmountResponse = await account.SendAmountUsingBuilder()
                                                                        .AddAddressAndAmount(receiverAddress, 1000000)
                                                                        .AddAddressAndAmount(receiverAddress, 2000000)
                                                                        .SendAmountAsync();


                Console.WriteLine($"SendAmountAsync: {sendAmountResponse}");
}

Examples ๐Ÿ˜

For more examples, see the Examples directory.

Supported Commands/Queries ๐Ÿ“‘

Wallet

Commands

  • CreateAccount
  • StoreMnemonic
  • VerifyMnemonic

Queries

  • GetAccount
  • GetAccounts
  • GetNewMnemonic

Account

Commands

  • BuildBasicOutput
  • BuildNftOutput
  • BurnNativeTokens
  • BurnNft
  • ClaimOutputs
  • ConsolidateOutputs
  • CreateAliasOutput
  • DestroyFoundry
  • EnablePeriodicSyncing
  • GenerateAddresses
  • MeltNativeTokens
  • MintNativeTokens
  • MintNfts
  • RequestFromFaucet
  • SendAmount
  • SendMicroAmount
  • SendNativeTokens
  • SendNfts
  • SendOutputs
  • SyncAccount

Queries

  • GetAddresses
  • GetAddressesWithUnspentOutputs
  • GetBalance
  • GetFoundryOutput
  • GetMinimumStorageDepositRequired
  • GetOutputs
  • GetPendingTransactions
  • GetTransaction
  • GetTransactions
  • GetUnspentOutputs