dSigner.ethers.js provides a straightforward method to create an ethers.js compatible signer object that integrates with Supabase for authentication and wallet management.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);The signIn() and signUp() methods are provided for development purposes only and should not be used in production environments. For production, it is recommended to use the Supabase SDK to manage authentication and then supply the access token to setAccessToken() as shown below.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);
await signer.signUp('[email protected]', 'your_super_secure_password');After signing up, please check your inbox for the email confirmation.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);
await signer.signIn('[email protected]', 'your_super_secure_password');For production implementations, use the access token generated by the Supabase SDK. The signIn() and signUp() methods provided above are for development convenience.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);
await signer.setAccessToken('SUPABASE_JWT_TOKEN');import dSigner from "./dSigner.ethers.node.js";
const signer = new dSigner(); // Yes, you may not need provider to sign message
await signer.setAccessToken('SUPABASE_JWT_TOKEN');
const signedMessage = await signer.signMessage('Message to sign');You can send transactions just as you would normally with ethers.js.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);
await signer.setAccessToken('SUPABASE_JWT_TOKEN');
const trx = await signer.sendTransaction({
to: signer.address, // Example: Sending to your own address
value: ethers.utils.parseEther('0.00001')
});
await trx.wait();
console.log(trx);Interacting with smart contracts is as seamless as it is with ethers.js.
import { ethers } from "ethers";
import dSigner from "./dSigner.ethers.node.js";
const provider = new ethers.providers.JsonRpcProvider('https://rpc-l1.jibchain.net');
const signer = new dSigner(provider);
await signer.setAccessToken('SUPABASE_JWT_TOKEN');
const Token = new ethers.Contract('YOUR_CONTRACT_ADDRESS', [
'function transfer(address to, uint256 value) external returns (bool)'
], signer);
const trx = await Token.transfer(
signer.address, // Example: Sending to your own address
ethers.utils.parseUnits('100')
);
await trx.wait();
console.log(trx.hash);