Signers
A Signer in theta.js is an abstraction of a Theta Account, which can be used to sign transactions and send signed transactions to the Theta Network to execute state changing operations.
The default Signer is a Wallet. This will be used for 99% of cases.
Create a random wallet
const wallet = thetajs.Wallet.createRandom();
Create a wallet from a mnemonic phrase
const phrase = 'WORDS_SEPARATED_BY_SPACE';
const wallet = thetajs.Wallet.fromMnemonic(phrase);
Create a wallet from a private key
const privateKey = '0x000000...000000';
const wallet = new Wallet(privateKey);
Create a wallet from an encrypted JSON file
const json = "YOUR_JSON_HERE";
const password = "YOUR_PASSWORD_HERE";
const wallet = Wallet.fromEncryptedJson(json, password);
Connecting a (new) provider
If you change providers after creating a wallet, you can connect to the new provider. This will return a new wallet instance.
const connectedWallet = myWallet.connect(myOtherProvider);
Updated almost 4 years ago
What’s Next