Authenticate
Example of how to use Bond JS SDK to authenticate.
import BondHub, { Blockchain, Env } from "@bondlab/client";
import Web3 from "web3";
const apiKey = process.env.BOND_API_KEY;
const appId = process.env.BOND_APP_ID;
const bondHub = new BondHub({
provider: Web3.givenProvider,
chain: Blockchain.POLYGON,
env: Env.STAGING,
apiKey,
appId,
})
// get challenge and autheniticate with the signature
await bondHub.login()
Or you can authenticate via seperate steps.
import BondHub, { Blockchain, Env } from "@bondlab/client";
const apiKey = process.env.BOND_API_KEY;
const appId = process.env.BOND_APP_ID;
const privateKey = process.env.WALLET_PRIVATE_KEY
const bondHub = new BondHub({
provider: Web3.givenProvider,
chain: Blockchain.POLYGON,
env: Env.STAGING,
apiKey,
appId,
}
const wallet = new ethers.Wallet(privateKey);
const address = await wallet.getAddress();
const challenge = await bondHub.generateChallenge(address);
const signature = await wallet.signMessage(challenge);
await bondHub.authenticate(address, signature);
Last updated