Create Wallet

To interact with the Arianee Protocol, a wallet is mandatory to store your NFTs.

Create wallet from private key

Method

const wallet = new Wallet({
    auth: {
      privateKey: '0x010930',
    },
  });
ParameterTypeMandatoryDescription
privateKeyStringβœ…A string representing 64 hex digits prefixed with 0x.
If empty, a random key is generated.

Create a wallet from mnemonic

πŸ“Œ

Generate a BIP-039 and BIP-044 wallet from mnemonic deriving path using the wordlist. The language is English (en). The derivation path is β€œm/44’/60’/0’/0/0”.

Method

const wallet = new Wallet({
    auth: {
      mnemonic:
        'sunset setup moral spoil stomach flush document expand rent siege perfect gauge',
    },
  });
ParameterTypeMandatoryDescription
mnemonicStringβœ…String representing with a 12-word passphrase.
If empty, a random mnemonic is generated.

Read public and private keys

When your wallet is instantiated, address and private key are available.

Method

let address = wallet.address;
let privateKey = wallet.privateKey;

Create instance between Arianee and external wallet - MetaMask Use Case

Create an instance between Arianee and an external wallet such as MetaMask for example.

const accounts = await window.ethereum.request({
  method: 'eth_requestAccounts',
});

const address: string = accounts[0];

this.core = new Core({
  getAddress: () => {
    return address;
  },
  signMessage: async (message) => {
    const signature = await window.ethereum.request({
      method: 'personal_sign',
      params: [address, message],
    });
    return { message, signature };
  },
  sendTransaction: async (transaction) => {
    return window.ethereum.request({
      method: 'eth_sendTransaction',
      params: [transaction],
    });
  },
});

this.wallet = new Wallet({
  chainType: 'testnet',
  auth: { core: this.core },
});

πŸ’‘

For more information about Core library, refer to the Core Library documentation.