PrivacyContent contract guide
Using the Relation PrivacyContent deployed by Relation Protocol, we can store and query users' identity data. The Relation PrivacyContent contract is an implementation of the PrivacyContent contract defined in the Contract Standard.
Construct a Contract object
The contract address and abi file of PrivacyContent and PrivacyContentWithSign contract can be accessed via Relation Protocol list of resources. You can construct a Contract object with "ethers".
import {ethers, providers} from 'ethers'
const getContractInstance = () => {
// Contract address
const contractAddress = '0x1A4231bedA090c6903c4731518C616F8FAEc5dc7'
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, privacyContentAbi, signer)
return contract
}
const getPrivacyContentWithSignContractInstance = () => {
// Contract address
const contractAddress = ''
const provider = new providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, privacyContentWithSignAbi, signer)
return contract
}Call methods of the contract
When a user pays gas fee
Prepare a token
A user needs to prepare a token, and passes the tokenId when calling the "post" method. Once the "post" method is called, the prepared token will be consumed.
Query th token prepared by a user:
Publish the content
A user can only publish the content Once a token is prepared. The content is encrypted via Lit Protocol, with the content uploaded to Arweave with the following format:
The subsequent transaction hash will be stored in the contract as the content's record.
Share the content to one's follower
Users can share the uploaded privacy content to their followers by specifying the tokenId and the address of the Follow contract sharing the content. A contract can only share with 20 Follow contract addresses to avoid query errors due to too many recursive calls.
Share the content to specified Dao
Users can share the uploaded privacy content to a certain Dao, and all Dao members can decrypt the privacy content via Lit Protocol. A contract can only share with 20 Dao contract addresses to avoid query errors due to too many recursive calls.
Query the list of Follow contract addresses that a tokenId has shared the content with:
The methods sharedFollowAddressCount and sharedFollowAddressByIndex can get the list of Follow contract addresses that a tokenId has shared the content with.
Query the list of Dao contract addresses that a tokenId has shared the content with:
The methods sharedDaoAddressCount and sharedFDaoAddressByIndex can get the list of Dao contract addresses that a tokenId has shared the content with.
Query the list of published contents of a user.
We can get the list of published contents of a user through said user's list of tokens.
Prepare a token(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.
Publish the content(Gas fee can be paid by someone else)
A user uploads the content to Arweave, 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.
Share the content with my followers(Gas fee can be paid by someone else)
A user signs against the tokenId and the Follow contract addresses to be shared with 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.
Share the content with specified Daos(Gas fee can be paid by someone else)
A user signs against the tokenId and the Dao contract addresses to be shared with 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