🔀Integrate with Jaypigs SDK

If your NFT Contract follows ERC-721

You decided to integrate with Jaypigs Cross-chain Renting solution, but your NFT smart contract follows the ERC-721 standard still? This is not an issue. We can help you deploy wrappers tailored to your needs. We are always happy to develop custom solutions for our clients. Please take contact with us through this email if you are interested to understand better: contact@jpigs.finance Here are some general guidelines to keep in mind:

  • If you want to stay on one chain only, we do not have a problem with that. We are happy to accomodate in that way. But keep in mind: Whenever you want to go cross-chain, we will be here to help you with that transition;

  • ERC-4907 wrappers can be deployed on multiple chains where ever you think is necessary.

  • Your users will be able to stake their original ERC-721, they will not even need to see the ERC-4907. We make sure that the technology stays in the background, so that users have the best user experience;

  • Every time a user asks to rent an NFT, we mint an ERC-4907 token on the desired chain and associate that wallet to that token as a User.

Now that you understand how the Jaypigs ecosystem functions, you can see that the only integration required from the developer's side is to grant user rights to the renter.

You can monitor the UpdateUser event or call userOf(uint256 tokenId) function to get the user on the desired chain, using the ERC-4907.

NEW: We will be releasing a full ERC-4907 API that will help you get that information easily off-chain without having to listen to UpdateUser events or call userOf(tokenId) function.

On-chain user rights verification example:

function getUser(address nftAddress, uint256 tokenId) public view returns (address) {
    return IERC4907(nftAddress).userOf(tokenId);
}

Off-chain user rights verification (using web3Js) example:

const Web3 = require("web3");
const rpcUrl = 'https://bsctestapi.terminet.io/rpc';
const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl));
const UpdateUserTopic =  web3.eth.abi.encodeEventSignature('UpdateUser(uint256,address,uint64)');

function decodeUpdateUserEvent(log) {
  // https://web3js.readthedocs.io/en/v1.3.0/web3-eth-abi.html#decodelog
  let result =  web3.eth.abi.decodeLog([
    {type: 'uint256',name: 'tokenId',indexed: true},
    {type: 'address',name: 'user',indexed: true},
    {type: 'uint64',name: 'expires'}],
    log.data,[log.topics[1],log.topics[2]]);

   return {token_id: result.tokenId, user: result.user, expires: result.expires};   
}


async function scanBlock(blockNumber, ERC4907AddressArray) {
  let logs = await web3.eth.getPastLogs(
    {fromBlock: blockNumber, toBlock: blockNumber,
       address: ERC4907AddressArray, topics: [UpdateUserTopic]});

  for (const log of logs) {
    let updateUserEvent = decodeUpdateUserEvent(log);
    
    //  {token_id: '6',user: '0x3569FEBAc68368F7CC8B2Cd01A528e8CbDAdb123',expires: '1666452779'}
    console.log({updateUserEvent})
    //  update user info to database 
    // ....
  }     
}

/*
  Just for demo.
  In product env, you need to scan each block block number 
  to get all UpdateUser events. 
*/
(async () => { java
 
  let blockNumber = 23785196
  // https://testnet.bscscan.com/address/0x6525374ea7ed0e9ed829ebe9a311906cf5c07efc
  const ERC4907AddressArray = ['0x6525374ea7ed0e9ed829ebe9a311906cf5c07efc'];
  await scanBlock(blockNumber, ERC4907AddressArray);
  
})()

Last updated