Existing blockchain accounts can be imported through the library in an Account object to allow for the use of the private key to sign messages.
Different options are available to make the connection:
the chain account private key
the chain account secret phrase
the use of a third-party browser web3 provider like metamask
the chain account details to stub an account object
Not all options are available on each chain module. Please refer below to see the connecting methods available for the needed chain.
1. From Private key or Secret Phrase
You can connect with any existing blockchain account by using the import_account function and passing in either the private key or the mnemonics of the account depending on the chain used.
Besides the private_key or mnemonics, other parameters like name, path, prefix or format can be passed in depending on the chain but are optional.
In the eventuality that both mnemonics and private_key are passed in, private_key will be ignored and mnemonics will be used to import the account.
// FUNCTION SIGNATUREawaitavalanche.import_account({ private_key:null, name:null})------------------------------------------------------------------------// EXAMPLEimport { avalanche } from'aleph-js'// Import account from private keyaccount =awaitavalanche.import_account({ private_key:'<YOUR PRIVATE KEY>'})// RETURNS THE ACCOUNT OBJECT{'private_key': '<PRIVATE KEY>','public_key': '<PUBLIC KEY>','address': '<ADDRESS>','type': 'AVAX','source': 'integrated','signer': '<KEYPAIR>','name': '<PASSED IN NAME OR ACCOUNT ADDRESS>'}
// FUNCTION SIGNATUREsolana.from_provider(provider)--------------------------------------------------------------------------// EXAMPLE// You are most likely using the wallet adapter @project-serum/sol-wallet-adapter// Provider would be the Wallet initliazed// provider = wallet import { solana } from'aleph-js'awaitsolana.from_provider(provider)// RETURNS AN ACCOUNT OBJECT{'private_key': null,'public_key': '<PUBLIC KEY>','address': '<PUBLIC KEY>','name': '<PUBLIC KEY>','type': 'SOL','source': 'provider','provider': provider }
3. From External Signer
Will return a stub account object with the passed in attributes. In this case, a message signature will be done by the signer.