Staking
Lock tokens to earn rewards or introduce a more fungible community token
A staking vault allowing owners of an ERC721 or ERC4907 collection to stake their NFTs and earn ERC20 tokens distributed based on the length of the lock up.
Getting Started
Module Methods
Smart Contract Methods
Getting Started
To begin we'll import the FrostySDK, chain configurations, and the Staking module.
Then we'll setup our signer (via wagmi/ethers) and create a new instance of the FrostySDK.
// Import SDK, chain configurations, and the Staking module
import { FrostySDK, chain, staking } from "frosty-sdk";
// Get the signer via wagmi or configure using ethers
// Setup the SDK with the desired chain and signer
const sdk = new FrostySDK(chain.goerli, signer);
Module Methods
deploy
Deploy a minimal proxy clone of the Staking implementation contract.
getContract
Get an ethers contract instance of a previously deployed Staking contract.
deploy
Deploy a minimal proxy clone of the Staking implementation contract.
const myStaking = await staking.deploy(
sdk,
nft,
token,
vaultDuration,
totalSupply,
onTxPending,
onTxReceipt
);
console.log("Staking deployed to: ", myStaking.address);
sdk (SDK)
An instance of the FrostySDK, configured with a chain and signer.
nft (string)
The address of the ERC721 that will be locked for staking rewards.
token (string)
The address of the ERC20 token that will be earned by staking ERC721 tokens.
vaultDuration (number)
The duration in days over which staking rewards may be earned.
totalSupply (number)
The total supply of the ERC721 collection that may earn staking rewards.
onTxPending (Function) - optional
A callback function executed upon submission of the deploy transaction.
onTxReceipt (Function) - optional
A callback function executed upon receipt of the deploy transaction.
getContract
Get an ethers contract instance of a previously deployed Staking contract.
const myStaking = await staking.getContract(sdk, address);
sdk (SDK)
An instance of the FrostySDK, configured with a chain and signer.
address (string)
The contract address of a previously deployed Rentable contract.
Smart Contract Methods
stake
Allows owners of the ERC721 collection to lock up their tokens for staking rewards.
claim
Allows owners of the ERC721 collection to claim and withdraw earned staking rewards.
claimForAddress
Distributes staking rewards on behalf of a specified account address.
unstake
Allows owners to claim earned staking rewards and unstake their tokens.
earningInfo
Returns the current staking rewards for the specified account address and tokens.
balanceOf
Returns the number of tokens staked by the specified account address.
tokensOfOwner
Returns the tokens currently staked by the specified account address.
stake
Allows owners of the ERC721 collection to lock up their tokens for staking rewards.
const myStaking = await staking.getContract(sdk, address);
const tokenIds = [0,1,2];
await myStaking.stake(tokenIds);
tokenIds (uint256[])
An array of tokens to lock in the staking vault.
claim
Allows owners of the ERC721 collection to claim and withdraw earned staking rewards.
const myStaking = await staking.getContract(sdk, address);
const tokenIds = [0,1,2];
await myStaking.claim(tokenIds);
tokenIds (uint256[])
An array of tokens to claim staked earning rewards against.
claimForAddress
Distributes staking rewards on behalf of a specified account address.
const myStaking = await staking.getContract(sdk, address);
const account = '0x1234567890123456789012345678901234567890';
const tokenIds = [0,1,2];
await myStaking.claimForAddress(account, tokenIds);
account (address)
The address of the account to claim on behalf of.
tokenIds (uint256[])
An array of tokens to claim staked earning rewards against.
unstake
Allows owners to claim earned staking rewards and unstake their tokens.
const myStaking = await staking.getContract(sdk, address);
const tokenIds = [0,1,2];
await myStaking.unstake(tokenIds);
tokenIds (uint256[])
An array of tokens to unstake and retreive from the staking vault.
earningInfo
Returns the current staking rewards for the specified account address and tokens.
const myStaking = await staking.getContract(sdk, address);
const account = '0x1234567890123456789012345678901234567890';
const tokenIds = [0,1,2];
await myStaking.earningInfo(account, tokenIds);
account (address)
The address of the account to check for earned staking rewards.
tokenIds (uint256[])
An array of tokens to check for earned staking rewards.
balanceOf
Returns the number of tokens staked by the specified account address.
const myStaking = await staking.getContract(sdk, address);
const account = '0x1234567890123456789012345678901234567890';
await myStaking.balanceOf(account);
account (address)
The address of the account to check for total number of staked tokens.
tokensOfOwner
Returns the tokens currently staked by the specified account address.
const myStaking = await staking.getContract(sdk, address);
const account = '0x1234567890123456789012345678901234567890';
await myStaking.tokensOfOwner(account);
account (address)
The address of the account to check for total number of staked tokens.
Updated over 1 year ago