Follow contract guide
Using the FollowRegister contract deployed by Relation Protocol, we can create a Follow contract for a user. The Follow contract can follow and unfollow someone. Both the FollowRegister and Follow contracts have implemented the contract interface defined by the Contract Standard.
Construct a Contract object
The contract addresses and abi files of the FollowRegister and FollowWithSign contract, and the abi file of the Follow contract, can be accessed via Relation Protocol list of resources. The address of the Follow contract can be accessed via FollowRegister, with each address having its own Follow contract.
Construct a FollowRegisterContract object with "ethers":
import { ethers, providers } from 'ethers'
const getFollowRegisterContractInstance = () => {
// FollowRegister contract address
const contractAddress = '0xab8Dde275F3d2508c578C5bbDf43E81964BF18A4'
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, followRegisterAbi, signer)
return contract
}
const getFollowWithSignContractInstance = () => {
const contractAddress = '0xAC0f863b66173E69b1C57Fec5e31c01c7C6959B7'
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, followWithSignAbi, signer)
return contract
}Call the methods of a contract
FollowRegister
Deploy the Follow contract:
Query the Follow contract of a user, and construct a Contract object.
Once a Follow contract is deployed by a user, the address of the contract can be acquired via the user's address.
Follow
Follow
To follow a certain address, a user will call the address's Follow contract:
Unfollow
A user's list of followers
We can get the list of followers of a user by querying the token owners of the user's Follow contract.
Follow(Gas fee can be paid by someone else)
A user signs against the data and constructs it into a parameter to be posted on the blockchain. Any address can initiate a transaction with this parameter, with the gas paid by said address.
Unfollow(Gas fee can be paid by someone else)
A user signs against the data and constructs it into a parameter to be posted on the blockchain. Any address can initiate a transaction with this parameter, with the gas paid by said address.
Last updated