Ce portefeuille exploite les liaisons wallet.rs officielles de l'IOTA et le porte sur .Net.
Désormais, les développeurs .Net peuvent également avoir la chance d’essayer IOTA/Shimmer !
dotnet ajoute le package IotaWallet.Net.Domain --prerelease
Ou téléchargez à partir d'ici.
dotnet ajoute le package IotaWallet.Net --prerelease
Ou téléchargez à partir d'ici.
Il prend actuellement en charge Windows x64
et Linux x86_64
.
Après avoir installé IotaWallet.Net.Domain
, lorsque vous construisez à l'aide dotnet build
, vous voyez un fichier libiota_wallet.so
. Il s'agit des liaisons rust précompilées. Vous devez l'ajouter à votre chemin de bibliothèque.
Exemple...
exporter LD_LIBRARY_PATH=""
Notez qu'il s'agit du chemin du dossier, pas du chemin du fichier.
Vous pouvez télécharger les nugets à partir du dépôt github lui-même. Regardez à droite sous Packages
.
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 } " ) ;
}
Pour plus d’exemples, consultez le répertoire Exemples.