Rentable

Rent to others or launch subscriptions.

An extension to Edition implementing ERC4907A / EIP4907 allowing token owner's to grant time restricted user rights to another account.

Getting Started
Module Methods
Smart Contract Methods

Getting Started

To begin we'll import the DecentSDK, chain configurations, and the Rentable module.

Then we'll setup our signer (via wagmi/ethers) and create a new instance of the DecentSDK.

// Import SDK, chain configurations, and the Rentable module
import { DecentSDK, chain, rentable } from "@decent.xyz/sdk";

// Get the signer via wagmi or configure using ethers
// Setup the SDK with the desired chain and signer
const sdk = new DecentSDK(chain.goerli, signer);

Module Methods

deploy
Deploy a minimal proxy clone of the Rentable implementation contract.

getContract
Get an ethers contract instance of a previously deployed Rentable contract.

deploy

Deploy a minimal proxy clone of the Rentable implementation contract.

const myNFT = await rentable.deploy(
  sdk,
  name,
  symbol,
  hasAdjustableCap,
  isSoulbound,
  maxTokens,
  tokenPrice,
  maxTokenPurchase,
  presaleMerkleRoot,
  presaleStart,
  presaleEnd,
  saleStart,
  saleEnd,
  royaltyBPS,
  feeManager,
  payoutAddress,
  contractURI,
  metadataURI,
  metadataRendererInit,
  tokenGateConfig,
  onTxPending,
  onTxReceipt,
  parentIP
);

console.log("Rentable deployed to: ", myNFT.address);

sdk (SDK)
An instance of the DecentSDK, configured with a chain and signer.

name (string)
The name of the NFT collection.

symbol (string)
The symbol of the NFT collection.

hasAdjustableCap (boolean)
Include the ability to change maxTokens at a date after deployment.

isSoulBound (boolean)
Implementation of Soulbound NFTs so that tokens in this collection are non-transferrable. Best set to true if NFTs are intended to be used as a credential or another purely non-financial use case.

maxTokens (number)
The total number of tokens allowed to be minted from the collection.

tokenPrice (BigNumber)
The price (in Wei) to mint a token from the collection.

maxTokenPurchase (number)
The maximum number of tokens allowed per mint.

presaleMerkleRoot (number | BigNumber)
A merkle root representation of the allowlisted accounts, and their relative max purchase and price per token.

import { MerkleTree } from 'merkletreejs';
import { ethers } from 'ethers';

const createMerkleRoot = (allowlist: Allowed[]) => {
  const leaves = allowlist.map((leaf) => {
    const address = leaf[0];
    const maxQuantity = leaf[1];
    const pricePerToken = ethers.utils.parseEther(leaf[2].toString());
    return ethers.utils.solidityKeccak256(
      ["address", "uint256", "uint256"],
      [address, maxQuantity, pricePerToken]
    );
  });
  const tree = new MerkleTree(leaves, ethers.utils.keccak256, { sortPairs: true });
  return tree.getHexRoot();
}

const presaleMerkleRoot = createMerkleRoot([
  ['0xce90a7949bb78892f159f428d0dc23a8e3584d75', 1, 0.1],
  ['0xab5801a7d398351b8be11c439e05c5b3259aec9b', 1, 0.1],
]);

presaleStart (number | BigNumber)
Unix time presale ends.

presaleEnd (number | BigNumber)
Unix time presale ends.

saleStart (number | BigNumber)
Unix time general sale starts. General sale applies to contracts deployed with and without an allowlist.

saleEnd (number | BigNumber)
Unix time general sale ends.

royaltyBPS (number)
Percentage of secondary sales for the contract creator.

feeManager (string)
The address of a deployed FeeManager (IFeeManager). Use zero address if your implementation does not require a fee structure.

payoutAddress (string)
An alternate address for withdrawals and royalty payments may be used. Use zero address as the default setting for owner payouts.

contractURI (string)
The URI for contract level metadata.

metadataURI (string)
The base URI for the collection metadata.

metadataRendererInit (MetadataRendererInit)
An object containing metadata to initialize with the on-chain metadata renderer.

type MetadataRendererInit = {
  description: string;
  imageURI: string;
  animationURI: string;
}

tokenGateConfig (TokenGateConfig) optional
The configuration for a token gate, an NFT contract from wich users must have a minimum balance to mint. Think of this as a more dynamic allowlist or light anti-sybil mechanism.

 type TokenGateConfig = {
  tokenAddress: string;
  minBalance: number;
  saleType: number;
}

enum SaleType {
  ALL = 0,
  PRESALE = 1,
  PRIMARY = 2
}

onTxPending (Function) - optional
A callback function executed upon submission of the deploy transaction.

onTxReceipt (Function) - optional
A callback function executed upon receipt of the deploy transaction.

parentIP (string) - optional
Implementation of EIP 5553 to assign token metadata to the address of another NFT with registered IP.

getContract

Get an ethers contract instance of a previously deployed Rentable contract.

const myNFT = await rentable.getContract(sdk, address);

sdk (SDK)
An instance of the DecentSDK, configured with a chain and signer.

address (string)
The contract address of a previously deployed Rentable contract.

Smart Contract Methods

setUser
Set a user and expiration for a token

userOf
Get the current user for a token

userExpires
Get the timestamp of expiration for a token

*All methods available on Edition are inherited and available on Rentable.

setUser

Set a user and expiration for a token

const myNFT = await rentable.getContract(sdk, address);
await myNFT.setUser(tokenId, user, expires);

tokenId (uint256)
The id of the token.

user (uint256)
The new user of the NFT.

expires (uint256)
The timestamp at which the user expires.

userOf

Get the current user for a token.

const myNFT = await rentable.getContract(sdk, address);
await myNFT.userOf(tokenId);

tokenId (uint256)
The id of the token.

userExpires

Get the timestamp of expiration for a token.

const myNFT = await rentable.getContract(sdk, address);
await myNFT.userExpires(tokenId);

tokenId (uint256)
The id of the token.


What’s Next