@atlantis-js/impact-certificate
v1.0.0
Published
SDK for Impact Certificate Minting and Attestation
Maintainers
Readme
Impact Certificate JS SDK
The @atlantis-js/impact-certificate is a JavaScript library for interacting with the Impact Certificate ecosystem. It provides functionality for minting Impact Certificates, checking mint status, fetching minted certificates, and performing attestations with staking, fetching attestations.
The library includes built-in type definitions, providing a great developer experience with IntelliSense in editors like VS Code.
Installation
npm install @atlantis-js/impact-certificateSupported Chains
The library supports the following blockchains:
- Arbitrum (Chain ID: 42161) - Supports Attestation
- Base (Chain ID: 8453)
- Celo (Chain ID: 42220) - Supports Attestation
- Optimism (Chain ID: 10)
Getting Started
Initialization
Initialize the client with the desired chain ID and provider/signer.
const ImpactCertificateClient = require("@atlantis-js/impact-certificate");
const { ethers } = require("ethers");
// Initialize provider (for read-only operations)
const provider = new ethers.JsonRpcProvider("YOUR_RPC_URL");
// Initialize signer (for write operations like minting and attesting)
const signer = new ethers.Wallet("YOUR_PRIVATE_KEY", provider);
const client = new ImpactCertificateClient({
chainId: 42161, // Arbitrum
provider: provider,
signer: signer
});Minting an Impact Certificate
const mintData = {
projectName: "My Impact Project",
projectStartDate: "2023-01-01",
projectEndDate: "2023-12-31",
backerName: "My Organization",
backerLogo: "https://example.com/logo.png",
projectDescription: "Description of the project...",
totalFundsDeployedUSD: 10000,
impactCoresAffected: ["Environment"],
impactBrief: "Brief description of impact...",
mediaLinks: ["https://example.com/report.pdf"],
paymentTransactionBlockchain: "Arbitrum",
paymentTokenAddress: "0x...", // Supported payment token address
mintBlockchain: "Arbitrum",
receiverAddress: "0x..." // Address to receive the NFT
};
try {
const response = await client.mint(mintData);
console.log("Mint request submitted:", response);
} catch (error) {
console.error("Minting failed:", error);
}Checking Mint Status
const requestId = "REQUEST_ID_FROM_MINT_RESPONSE";
const status = await client.getMintStatus(requestId);
console.log("Mint status:", status);Fetching Minted Certificates
const tokens = await client.getAllMinted();
console.log("Minted tokens:", tokens);Attesting to an Impact Certificate
Attestation requires staking tokens. The SDK handles staking automatically if the user has insufficient stake.
const tokenId = 0; // ID of the token to attest to
const accept = true; // Approve the impact claim
const comment = "Verified impact.";
try {
// Check stake and stake if necessary
const userAddress = await signer.getAddress();
const hasStake = await client.hasSufficientStake(userAddress);
if (!hasStake) {
const tokens = await client.getWhitelistedTokens();
if (tokens.length > 0) {
await client.stake(tokens[0].address);
}
}
// Perform attestation
const attestationUid = await client.attest(tokenId, accept, comment);
console.log("Attestation successful! UID:", attestationUid);
} catch (error) {
console.error("Attestation failed:", error);
}Fetching Attestations
const attestations = await client.getAttestations();
console.log("Attestations:", attestations);API Reference
ImpactCertificateClient
constructor(options): Initializes the client.mint(mintData): Mints a new certificate.getMintStatus(requestId): Gets the status of a mint request.getAllMinted(): Fetches all minted certificates.attest(tokenId, accept, comment): Attests to a certificate.getWhitelistedTokens(): Gets tokens whitelisted for staking.hasSufficientStake(userAddress): Checks if a user has sufficient stake.stake(tokenAddress): Stakes tokens.getAttestations(schemaUid): Fetches attestations for a schema.
License
MIT
