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.
const wallet = thetajs.Wallet.createRandom();
const phrase = 'WORDS_SEPARATED_BY_SPACE'; const wallet = thetajs.Wallet.fromMnemonic(phrase);
const privateKey = '0x000000...000000'; const wallet = new Wallet(privateKey);
const json = "YOUR_JSON_HERE"; const password = "YOUR_PASSWORD_HERE"; const wallet = Wallet.fromEncryptedJson(json, password);
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 over 1 year ago