Using an account
Writing to the network requires a blockchain account which will serve as the referenced account on the resource generated.
On a blockchain, every message is sent from an address and signed using a keypair. The combination of those two parameters is referred as an account.
Inside your keypair, is a private key that should never be exposed to anyone or any service, and a public key* that you share to the network as a proof of identity.
You'll find below, the list of currently supported chain:
Avalanche
Cosmos
Ethereum
NULS2
Solana
Substrate
Tezos
The Aleph Typescript SDK offers 3 ways of retrieving an account, depending on the use case. Not all chains support every methods so make sure to check the API reference
*On some accounts, the address is the same as the public key.
A demo tool is available to let you test accounts' connexion with:
Web3provider
Hardware
keypair
You can try it from there in the typescript SDK.
Create or retrieve an account using a mnemonic/private key
The most basic way of retrieving an account is by using the private key. Your private key should remain secret and should never be exposed in your codebase. The way you store and manage your keys is entirely up to you. This method is best suited when you need to use your own private keys, if you need to work on frontend applications, refer to the Retrieve an account using a Web3 Provider section below, which provides a better way for your users to authenticate.
This example shows how to import an Ethereum account using a private key:
Alternatively you can also import an account from a bip39 mnemonic. Mnemonics are a more convenient way to store private keys, however the same golden rule still applies: they have to remain secret! The example shows how you can import the same account, but from its mnemonic.
Create an account from a random combination
This feature is mostly designed for test purposes. We strongly encourage you to use Web3Provider for your login process.
Another approach is to initiate a random account using the NewAccount() method. This method is available for all the protocols.
You can refer to the account API reference for more details about the return value from NewAccount() for each protocol.
Retrieve an account using a Web3 Provider
If you need to allow your user to use their account on your frontend application, the easiest way is to use a provider. Currently only the Solana, Alanche and Ethereum accounts support this method.
When calling the GetAccountFromProvider
method, your user will be prompted to open their default wallet (ex: Metamask for Ethereum, Phantom for Solana). If an account was instanciated using a provider, signing and encryption (if available) will be handled by the provider keypair and won't be stored in the account. For each signing operation (ex: sending a message on the Aleph network) the user will be prompted by their wallet to sign the transaction.
Retrieve an account using a hardware cold storage wallet (Ledger)
Additionally to web3 providers, you might want to allow the use of a cold storage wallet for your application. At this moment only Ethereum is supported on Ledger.
You only need to call the GetAccountFromLedger() method to initiate the connexion. For this Ledger connexion, your user must have his ledger connected to his device, with the Ethereum application opened.
Then whenever your user will have to sign a transaction a summary will be printed on his device to accept it.
Last updated