Create Smart Contract Wallet
Create a Smart Contract Wallet
The init method is a fundamental feature of the FuseBox JS SDK that enables you to setup a wallet by parsing the PRIVATE_KEY from an EOA. In the example below, we parse the PRIVATE_KEY and YOUR_API_KEY to the init method. Get YOUR_API_KEY here. We use the EthersJS library to access the PRIVATE_KEY of the EOA. After a Smart Contract Wallet has been initialized, we can read it using the getSender() method.
Note: Developers can use the EthersJS createRandom() to create new random Wallets.
import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";
const main = async () => {
const publicApiKey = "YOUR_API_KEY" as string;
const credentials = new ethers.Wallet("PRIVATE_KEY" as string);
const fuse = await FuseSDK.init(publicApiKey, credentials);
console.log(`Sender Address is ${fuseSDK.wallet.getSender()}`);
};
main();