Backend wallet quickstart
This guide will walk you through creating and managing backend wallets using the Openfort Node SDK.
Create a backend wallet
Backend wallet (dac
) can be used for escrow, minting, and transferring assets. You can create a new custodial backend wallet or add your own external account by providing a signature and address.
Node.js
const developerAccount = await openfort.settings.createDeveloperAccount({
name: "Minting Account"
});
console.log("Success! Here is your backend wallet id: " + developerAccount.id);
Add a contract to Openfort
We'll use a simple ERC-721 contract on the Polygon Amoy network.
Once added, Openfort will return a contract id that starts with con_
.
curl https://api.openfort.io/v1/contracts \
-H "Authorization: Bearer $YOUR_SECRET_KEY" \
-d chainId=80002 \
-d address="0x2522F4Fc9aF2E1954a3D13f7a5B2683A00a4543A" \
-d abi=[
{
"inputs": [
{
"internalType": "address",
"name": "_to",
"type": "address"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
] \
-d name="Simple NFT"
Mint an NFT using the backend wallet
Use your backend wallet to mint an NFT. The wallet will be used to pay for gas fees.
Make sure to replace the contract id with your own.
Node.js
const contractId = "con_...";
const chainId = 80002;
const optimistic = false;
const tokenId = '1'; // Token ID to mint, should be unique
const interaction_mint = {
contract: contractId,
functionName: "mint",
functionArgs: [developerAccount.address, tokenId],
};
const transactionIntent = await openfort.transactionIntents.create({
"account": developerAccount.id,
"chainId": chainId,
"optimistic": optimistic,
"interactions": [interaction_mint]
});
console.log("Success! Here is your transactionIntent id: " + transactionIntent.id);