Create Smart Contract Wallet
Initialization
The init
method is a fundamental feature of the SDK that enables you to setup a wallet & authenticate the user's provided credentials. The method requires the use of a PRIVATE_KEY
which you can get in the Fuse Developer Console here. When you send a request to the server using this method, it verifies the credentials and if the credentials are valid, developers can use the getSender()
to return an address.
- Web
- Flutter
import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";
const apiKey = "API_KEY";
const credentials = new ethers.Wallet("PRIVATE_KEY");
const fuseSDK = await FuseSDK.init(apiKey, credentials);
Access the wallet
// Create Wallet
const smartContractAddress = fuseSDK.wallet.getSender();
console.log(`Sender Address is ${smartContractAddress}`);
//Enter your Fuse Developer API Key
final apiKey = 'API_KEY';
// Generate a random Ethereum private key
final String privateKey = await Mnemonic.generatePrivateKey();
final EthPrivateKey credentials = EthPrivateKey.fromHex(privateKey);
final fuseSDK = await FuseSDK.init(apiKey, credentials);
Access the wallet
// Create Wallet
final smartContractAddress = fuseSDK.wallet.getSender();
print('Smart contract wallet address: $smartContractAddress');