Socios.com Connect
Chiliz ChainChiliz Labs
  • Socios.com Connect
  • INTERACT WITH CHILIZ CHAIN
    • Overview
    • Prerequisites
    • Working with Tokens
    • Working with NFTs
    • Working with Transactions
    • Working with Polls
    • Working with Staking
  • Partner API
    • Overview
    • 2025 API Update Overview
    • Prerequisites
    • Quick start
    • Authentication
    • API Reference
      • Data API
        • Data API endpoints
      • NFT API
        • NFT API endpoints
      • Ping API
      • Polls API
        • Polls API endpoints
      • Rewards API
        • Rewards API endpoints
      • User API
        • User API endpoints
      • Wallet API
        • Wallet API endpoints
  • Partner web app
    • Overview
    • Integration
    • URL parameters
    • On-Ramp Fan Tokens
Powered by GitBook
On this page
  • About "Stake & Earn"
  • Implementing Socios.com staking/unstaking on your own site
  • Set up your Chiliz Viem Client
  • Staking
  • What's staked
  • Unstaking
  • Checking the cooldown period
  • Claiming (after cooldown period)
  1. INTERACT WITH CHILIZ CHAIN

Working with Staking

Socios.com users have two ways to do in-app staking:

  • Staking Fan Tokens.

  • Staking CHZ.

Furthermore, Socios.com partners can implement the Socios.com Fan Token staking mechanism on their own website.

This page contains sample code to achieve that.

About "Stake & Earn"

By staking their Fan Tokens through their Socios.com Wallet, Socios.com users can earn Reward Points on a daily basis, and possibly get quick access to great Socios.com rewards and activities!

Each staked Fan Token will join an existing pool of rewards points, made of all the Fan Tokens staked by all Socios.com users.

The pool then works for all users, and the more Fan Tokens you have staked, the more reward points you can obtain in return.

Fan Token staking is also possible from wallets other than Socios.com Wallet.

This allows anyone to contribute to the Fan Token ecosystem, but staking from non-Socios wallets cannot earn Socios.com reward points.

There is only one smart contract address to stake any of the Socios.com Fan Tokens: 0x5ff7f9724fd477d9a07dcdb894d0ca7f8fae1501

Implementing Socios.com staking/unstaking on your own site

Socios.com partners can implement Fan Token staking right into their own platform.

This is done through a specific smart contract created by the Socios.com team. This Staking smart contract has 5 main features:

  • Staking

  • Locking

  • Processing the locks

  • Unstaking

  • Claiming

To implement staking, unstaking, and the other necessary fixtures, we provide you with the following sample code listing, ready for you to adapt to your own codebase.

Set up your Chiliz Viem Client

import { createPublicClient, http, createWalletClient } from 'viem'
import { chiliz, spicy } from 'viem/chains'
import { privateKeyToAccount } from 'viem/accounts';

const publicClient = createPublicClient({
	chain: chiliz, // chiliz (mainnet) or spicy (testnet)
	transport: http() // you can overwrite the transport URL provided by Chain object here 
})

const privateKey = '0xSenderPrivateKey'; // Replace with the sender's private key
const account = privateKeyToAccount(privateKey);
const walletClient = createWalletClient({
	account: '0x',
	chain: chiliz, // chiliz (mainnet) or spicy (testnet)
	transport: http()
})

Staking

import { abi as stakingABI } from './FTStakingABI.json';

async function stake(amount, tokenAddress) {
  const txHash = await walletClient.writeContract({
    address: '0xFanTokenStakingAddress', // Replace with the Fan Token Staking contract address
    abi: stakingABI,
    functionName: 'stake', // Function to stake tokens
    args: [amount, tokenAddress],
  });
  return publicClient.waitForTransactionReceipt({ hash: txHash });
}

// Example usage. Replace 10 with the exact amount to stake, and 0xFanTokenAddress with the actual Fan Token contract address.
stake(10, '0xFanTokenAddress',).then(console.log);

What's staked

import { abi as stakingABI } from './FTStakingABI.json';

async function getStakeDataLatest(staker, fanToken, perEventType) {
  const stakeData = await publicClient.readContract({
    address: '0xFanTokenStakingAddress', // Replace with the Fan Token Staking contract address,
    abi: stakingABI,
    functionName: 'getStakeDataLatest',
    args: [staker, fanToken, perEventType],
  });
  return stakeData;
}

// Example usage, Replace 0xStakerWalletAddress with the actual staker wallet address, and 0xFanTokenAddress with the actual Fan Token contract address.
getStakeDataLatest('0xStakerWalletAddress', '0xFanTokenAddress').then(console.log);

Unstaking

import { abi as stakingABI } from './FTStakingABI.json';

async function unstake(amount, tokenAddress) {
  const txHash = await walletClient.writeContract({
    address: '0xFanTokenStakingAddress', // Replace with the Fan Token Staking contract address
    abi: stakingABI,
    functionName: 'unstake', // Function to unstake tokens
    args: [amount, tokenAddress],
  });
  return publicClient.waitForTransactionReceipt({ hash: txHash });
}

// Example usage. Replace 10 with the exact amount to unstake, and 0xFanTokenAddress with the actual Fan Token contract address.
unstake(10, '0xFanTokenAddress',).then(console.log);

Checking the cooldown period

import { abi as stakingABI } from './FTStakingABI.json';

async function getCooldownPeriod() {
  const cooldownPeriod = await publicClient.readContract({
    address: '0xFanTokenStakingAddress', // Replace with the Fan Token Staking contract address,
    abi: stakingABI,
    functionName: 'unstakePeriod', // The function that returns the unstake period.
    args: [],
  });
  return cooldownPeriod.toString();;
}

// Example usage.
getCooldownPeriod().then(console.log);

Claiming (after cooldown period)

import { abi as stakingABI } from './FTStakingABI.json';

async function claim(amount, tokenAddress) {
  const txHash = await walletClient.writeContract({
    address: '0xFanTokenStakingAddress', // Replace with the Fan Token Staking contract address
    abi: stakingABI,
    functionName: 'claim', // Function to claim tokens
    args: [amount, tokenAddress],
  });
  return publicClient.waitForTransactionReceipt({ hash: txHash });
}

// Example usage. Replace 0xFanTokenAddress with the actual Fan Token contract address.
claim('0xFanTokenAddress',).then(console.log);

PreviousWorking with PollsNextOverview

Last updated 2 days ago