ajuna-network / SubstrateNetApi

Just another Substrate .NET API
Apache License 2.0
38 stars 12 forks source link

wallet.AccountInfo is null #21

Open ArtemShe opened 2 years ago

ArtemShe commented 2 years ago

Hi! I'm new in crypto. Trying to use your SDK Idea its to create wallets and manage them- at least see balances and transfer 'money' between wallets. As I understood - balance information is placed at wallet.AccountInfo.AccountData Problem that when wallet is created or loaded -wallet.AccountInfo is null Using different domains

I debug SDK code and looks like my problem here (class Wallet) image

So what should I do to have wallet.AccountInfo?

Regards)

darkfriend77 commented 2 years ago

Hi,

Did you tried with an Account that exists?

ArtemShe commented 2 years ago

I'm confused) According code of class Wallet method CreateAsync that contains a line Account = Account.Build(keyType, privateKey, publicKey); this method create account, and account means/equals a wallet.

Could you provide example of code with your SDK how to create account/wallet from scratch and check balance.

Another interesting point is that looks like Wallet.CreateAsync generate public and private key of wallet at client side. Its also unclear for because 1) usually server return to client "Id" on registration 2) Looks like Wallet.CreateAsync logic not depend on sever/network, but regarding documentation - base on network is start with specifics symbols. And this SDK generate public key not regarding this rules.

Regards)

darkfriend77 commented 2 years ago

That's correct the private key is generated client-side and is encrypted with a seed you provide.

This will not create an account on the blockchain itself for that purpose you will need to create a transaction sending you some tokens at that point your public key will be registered on the chain as an account. maybe that can clarify some of your questions, https://support.polkadot.network/support/solutions/articles/65000168651-what-is-the-existential-deposit-

darkfriend77 commented 2 years ago

Here is an example of how to create a transaction.

https://github.com/ajuna-network/SubstrateNetApi/blob/c98ab81275d8c5ac6cbd48c00688ab1b8ae6496a/IntegrationTest/LocalNodeTests.cs#L248

As we are currently heavily refactoring the API, you might wait for one a few days then I will provide more code snippets with the most actual monthly release which makes everything much more smooth with the newest API release.

RostislavLitovkin commented 1 year ago

Hello, could you please also provide the example how to get the current balance?

darkfriend77 commented 1 year ago

Sure, The easiest way is that you create your SDK for your node with this repository. https://github.com/ajuna-network/Ajuna.SDK

Use this step-by-step https://github.com/ajuna-network/Ajuna.SDK#installing-the-template

If you exchange here SystemStorage.Number with SystemStorageAccountInfo your are good to go. https://github.com/ajuna-network/Ajuna.SDK.Demos/blob/master/Ajuna.SDK.Demos.DirectPolling/Program.cs