Content contract guide
Using the Relation Content deployed by Relation Protocol, we can store and query a user's identity data. The Relation Content contract is an implementation of the Content contract defined by the Contract Standard.
Construct a Contract object
The address and abi file of the Content contract and the ContentWithSign contract can be accessed via Relation Protocol's list of resources. You can construct a Contract object using "ethers":
import { ethers, providers } from 'ethers'
const getContractInstance = () => {
// Contract address
const contractAddress = '0xAC0f863b66173E69b1C57Fec5e31c01c7C6959B7'
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, contentAbi, signer)
return contract
}
const getContentWithSignContractInstance = () => {
// Contract address
const contractAddress = ''
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, contentWithSignAbi, signer)
return contract
}How to call a contract
Pay the gas fee by oneself
Publish content
A user can upload the content to be published to Arweave with the following format:
The subsequent transaction hash will be recorded as content in the contract.
Query the list of content published by a user
We can get the list of content published by a user through the list of tokens the user holds.
Pay for someone else's gas fee
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.
Publish content(Gas fee can be paid by someone else)
A user can upload the content to be published to Arweave with the following format:
The subsequent transaction hash will be used to construct a parameter to be posted on the blockchain. The address paying for the gas fee should use this parameter to call the contract.
Last updated