wallet.signMessage
. Below is a full example of how to sign and recover a message. // #import { WalletUnlocked, hashMessage, Signer };
const wallet = WalletUnlocked.generate({
provider,
});
const message = 'doc-test-message';
const signedMessage = await wallet.signMessage(message);
const hashedMessage = hashMessage(message);
const recoveredAddress = Signer.recoverAddress(hashedMessage, signedMessage);
wallet.signTransaction
. Below is a full example of how to sign and recover a transaction. // #import { Provider, Wallet, Signer };
const provider = await Provider.create(FUEL_NETWORK_URL);
const wallet = Wallet.fromPrivateKey(PRIVATE_KEY, provider);
const signedTransaction = await wallet.signTransaction(SCRIPT_TX_REQUEST);
const chainId = wallet.provider.getChainId();
const verifiedAddress = Signer.recoverAddress(
SCRIPT_TX_REQUEST.getTransactionId(chainId),
signedTransaction
);