Original NFT method call

In order to execute calls on original NFT, there are a couple of pre-requisites one must be aware of:

  • The caller must be the owner of a wrapper token for the original NFT token (or sign a transaction with its private key, in case of meta transactions

  • The method must be whitelisted by the lender (valid for state-changing calls, not for read-only methods)

Calling state-changing method

The method call will be targeted at the original NFT contract mirrored by the wrapper contract and can also accept the value that will be forwarded to the target contract. This can be done by calling the method on wrapper contract:

function executeCall(
    uint256 tokenId, 
    bytes calldata data, 
    bytes calldata signature
) external payable;
  • tokenId - must be provided as a parameter so the whitelist of method selectors can be checked if the method defined by data can be called on the original contract, if it has a value at all. In essence, this call takes into consideration if the method selector extracted from data is checked if it’s whitelisted.

  • data (can be empty value) - represents call data being passed upon forwarding and it's also used to extract the target method selector in order to check the whitelist if set. In case this parameter has no value, the call is forwarded without checking the whitelist.

  • signature (can be empty value) - generated based on data on the client side of the application and is useful in case there is a gas station functionality or transaction delegation. Based on the signature and data, the signer is extracted and used as the sender. This parameter is optional and in case it has no value, the original sender of the transaction will be taken into account.

Example of generating a signature for data

// Using Ethers.js lib for signing and hashing
// data would be calldata being forwarded (expected as hexstring)
const dataHash = ethers.utils.keccak256(data);
const dataHashBin = ethers.utils.arrayify(dataHash);
// signer is type of Signer class defined in Ethers.js lib
const signature = await signer.signMessage(dataHashBin);
return signature;

In order to call any static call (eg. calling balanceOf method) on the original contract, the wrapper contract has implemented fallback function which will just forward the call to the original contract. This method does not check if the method is whitelisted, therefore any read call on the original contract is allowed.

In order to invoke it, make a static call to the wrapper contract with encoded data of the call, which will be forwarded to the original contract.

Last updated