Skip to content

API Reference

This section details the public API of the core CommissionRoad contracts.


CommissionRoad

The main entry point for the protocol.

Public Variables

VariableTypeDescription
ETH_ADDRESSaddressSentinel address used to represent native ETH (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE).
mintFeeuint256The fee (in wei) required to mint a new CommissionRoad NFT.
commissionRoadNFTCommissionRoadERC721Reference to the ERC721 contract that manages CommissionRoad NFTs.
commissionVaultICommissionVaultReference to the vault contract that stores and manages commission funds.
isCallTargetAllowlistedmapping(uint256 => mapping(address => bool))Per-NFT mapping of call targets that are allowed when the allowlist is enabled.
isAllowlistEnabledmapping(uint256 => bool)Per-NFT flag indicating whether the allowlist is active.

Events

EventParametersDescription
CommissionCalluint256 indexed nftId, address indexed user, address commissionToken, uint256 commissionEmitted when a commission call is made.
AllowlistUpdateduint256 indexed nftId, address indexed target, bool allowedEmitted when a allowlist entry is added or removed.
AllowlistEnabledUpdateduint256 indexed nftId, bool enabledEmitted when the allowlist is enabled or disabled.

Errors

ErrorParametersDescription
CommissionCallFaileduint256 index, uint256 msgValueThrown when a call in the batch fails.
InvalidNftIdThrown when a referenced NFT ID does not exist.
IncorrectMintFeeAmountThrown when the mint fee sent does not match mintFee.
CallTargetNotAllowlisteduint256 nftId, address targetThrown when a call target is not allowlisted and the allowlist is enabled.
NotNftOwneruint256 nftIdThrown when the caller is not the owner of the specified NFT.

mint / mintTo

Mints a new CommissionRoad NFT ID. The caller must pay the mintFee (in ETH).

solidity
// Mint to msg.sender
function mint() external payable returns (uint256 nftId);

// Mint to a specific address
function mintTo(address to) external payable returns (uint256 nftId);

// Mint to msg.sender with metadata
function mint(CommissionRoadERC721.Metadata memory metadata) external payable returns (uint256 nftId);

// Mint to a specific address with metadata
function mintTo(address to, CommissionRoadERC721.Metadata memory metadata) external payable returns (uint256 nftId);

Parameters

ParameterTypeDescription
toaddressThe address that will receive ownership of the minted NFT. If omitted (using mint()), defaults to msg.sender.
metadataMetadataOptional on-chain metadata to associate with the NFT. See Metadata Struct for details.

Returns

TypeDescription
uint256The newly minted NFT ID.

Emitted Events

  • Standard ERC721 Transfer event (from CommissionRoadERC721)

commissionCall

Executes a batch of calls to target contracts and collects a commission.

solidity
struct BatchCallData {
    address target;
    bytes callData;
    uint256 value;
}

function commissionCall(
    BatchCallData[] calldata batchCallData,
    uint256 nftId,
    address commissionToken,
    uint256 commission
) external payable;

Parameters

ParameterTypeDescription
batchCallDataBatchCallData[]Array of calls to execute sequentially. See BatchCallData Struct below.
nftIduint256The ID of the CommissionRoad NFT that will receive the commission. Must be a valid, minted NFT ID.
commissionTokenaddressThe address of the token to take the commission in. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for ETH.
commissionuint256The total commission amount to collect. The protocol fee is automatically deducted, with the remainder going to the NFT owner.

BatchCallData Struct

MemberTypeDescription
targetaddressThe contract address to call. Cannot be the CommissionRoad.commissionCall method itself (reentrancy protected).
callDatabytesThe encoded function call data (use abi.encodeWithSelector or similar).
valueuint256The ETH value (in wei) to send with this specific call.

Reentrancy Protection

You cannot call back into CommissionRoad from a target contract during a commissionCall.

msg.value Requirements

When sending ETH, any excess ETH is refunded to msg.sender. Ensure your value calculation is precise to avoid reverts, or send slightly more to rely on the refund.

Suggested Reading

Emitted Events


commissionPlan

Executes a Weiroll script (commands and state) and collects a commission. Used for dependent transaction flows.

solidity
function commissionPlan(
    bytes32[] calldata commands,
    bytes[] calldata state,
    uint256 nftId,
    address commissionToken,
    uint256 commission
) external payable;

Parameters

ParameterTypeDescription
commandsbytes32[]Array of Weiroll command bytes. Each command encodes a function call with flags specifying how inputs/outputs should be handled. See Weiroll documentation for encoding details.
statebytes[]Array of state slots used by the Weiroll VM. These slots store intermediate values that can be passed between commands, enabling dependent transaction flows.
nftIduint256The ID of the CommissionRoad NFT that will receive the commission. Must be a valid, minted NFT ID.
commissionTokenaddressThe address of the token to take the commission in. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for ETH.
commissionuint256The total commission amount to collect. The protocol fee is automatically deducted, with the remainder going to the NFT owner.

Reentrancy Protection

You cannot call back into CommissionRoad.commissionPlan from a target contract during a commissionPlan.

Suggested Reading

Emitted Events


setAllowlist

Adds or removes an address from the allowlist for a given NFT. The allowlist must also be enabled for it to take effect.

solidity
function setAllowlist(
    uint256 nftId,
    address target,
    bool allowed
) external;

Parameters

ParameterTypeDescription
nftIduint256The NFT ID to configure. Caller must be the owner.
targetaddressThe contract address to add or remove.
allowedbooltrue to allowlist the target, false to remove it.

Emitted Events

Suggested Reading


setAllowlistEnabled

Enables or disables the allowlist for a given NFT. When enabled, only allowlisted targets can be called via commissionCall and commissionPlan.

solidity
function setAllowlistEnabled(
    uint256 nftId,
    bool enabled
) external;

Parameters

ParameterTypeDescription
nftIduint256The NFT ID to configure. Caller must be the owner.
enabledbooltrue to enable the allowlist, false to disable it.

Emitted Events

Suggested Reading


CommissionVault

Handles storing and claiming commissions.

Public Variables

VariableTypeDescription
ETH_ADDRESSaddressSentinel address used to represent native ETH (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE).
protocolFeePercentuint256The percentage (in 18-decimal fixed point) of each commission that goes to the protocol.
pendingCommissionsmapping(uint256 => mapping(address => uint256))Nested mapping of NFT ID → token address → pending commission amount available to claim.
commissionRoadNFTCommissionRoadERC721Reference to the ERC721 contract used for ownership verification.

Events

EventParametersDescription
CommissionClaimeduint256 indexed nftId, address indexed owner, address[] tokens, uint256[] amountsEmitted when commissions are claimed.
ProtocolFeeCollectedaddress token, uint256 amountEmitted when a protocol fee is deducted from a deposit.

claim / claimTo

Claims collected commissions for a specific NFT ID. Only the owner of the NFT can call this.

solidity
struct ClaimData {
    address token;
    uint256 amount;
}

// Claim to msg.sender
function claim(
    uint256 nftId,
    ClaimData[] calldata claimData
) external;

// Claim to a specific address
function claimTo(
    uint256 nftId,
    ClaimData[] calldata claimData,
    address destination
) public;

Parameters

ParameterTypeDescription
nftIduint256The NFT ID to claim commissions for. Caller must be the owner of this NFT.
claimDataClaimData[]Array of claim data specifying tokens and amounts to claim. See ClaimData Struct below.
destinationaddress(claimTo only) The address to send the claimed funds to. Allows claiming to a different wallet than the NFT owner.

ClaimData Struct

MemberTypeDescription
tokenaddressThe token address to claim. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for ETH.
amountuint256The amount of commissions to claim for this token. If the amount exceeds the available balance, only the available amount is claimed.

Emitted Events


depositCommission

Deposits a commission into the vault. Normally called internally by CommissionRoad, but can be called directly by any contract or user.

solidity
function depositCommission(
    uint256 nftId,
    address token,
    uint256 amount
) external payable;

Parameters

ParameterTypeDescription
nftIduint256The NFT ID to deposit commissions for. The owner of this NFT will be able to claim these funds.
tokenaddressThe address of the token being deposited. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for ETH.
amountuint256The amount of tokens to deposit. For ETH, must equal msg.value.

NOTE

A protocol fee (based on protocolFeePercent) is automatically deducted from the deposit.

Emitted Events


CommissionRoadERC721

The NFT contract representing CommissionRoad IDs.

Public Variables

VariableTypeDescription
PROTOCOL_NFT_IDuint256Constant value 0. The NFT ID that represents protocol ownership. The owner of this NFT is the protocol admin.
nextAvailableNftIduint256The next NFT ID that will be minted. Also represents the total number of NFTs minted.
tokenURIContractTokenURIReference to the contract that generates token URI metadata.
authorizedmapping(address => bool)Mapping of addresses authorized to mint NFTs (e.g., the CommissionRoad contract).

transferFrom

Transfers ownership of an NFT from one address to another.

solidity
function transferFrom(
    address from,
    address to,
    uint256 id
) public;

Parameters

ParameterTypeDescription
fromaddressThe current owner of the NFT. Must match the actual owner or the caller must be approved.
toaddressThe address to transfer ownership to. Cannot be the zero address.
iduint256The NFT ID to transfer. Must be a valid, minted NFT.

safeTransferFrom Not Supported

This contract explicitly reverts on safeTransferFrom to prevent reentrancy and complex callback exploits. Use transferFrom instead.


tokenURI

Returns the metadata URI for a given token ID. The URI is a Base64 encoded JSON string.

solidity
function tokenURI(uint256 nftId) public view returns (string memory);

Parameters

ParameterTypeDescription
nftIduint256The ID of the NFT to get the token URI for. Must be a valid, minted NFT.

Returns

TypeDescription
stringA Base64-encoded data URI containing JSON metadata.

Example JSON Output

json
{
  "name": "CommissionRoadId 0",
  "description": "CommissionRoad is a NFT-based monetization protocol. This NFT holds the rights to claim commissions. Note: Commissions are automatically claimed on NFT transfer",
  "image_data": "data:image/svg+xml;base64,...",
  "attributes": [
    {
      "trait_type": "CommissionRoad Id",
      "value": "0"
    },
    {
      "trait_type": "Owner",
      "value": "0x..."
    }
  ]
}

setMetadata

Updates the metadata for an NFT. Only the owner can call this.

solidity
function setMetadata(uint256 nftId, Metadata memory metadata) public;

Parameters

ParameterTypeDescription
nftIduint256The ID of the NFT to update metadata for. Caller must be the owner.
metadataMetadataThe new metadata struct to set. See Metadata Struct below.

Metadata Struct

MemberTypeDescription
namestringA custom display name for the NFT (e.g., "My Brand ID").
descriptionstringA description of the NFT or its purpose.
imageUrlstringURL to a custom image for the NFT.
ensstringAssociated ENS name (e.g., "myname.eth").
websitestringWebsite URL associated with this NFT.
socialsSocialsSocial media links. See Socials Struct below.

Socials Struct

MemberTypeDescription
telegramstringTelegram username or link.
discordstringDiscord username or invite link.
instagramstringInstagram handle or profile URL.
snapchatstringSnapchat username.
tiktokstringTikTok username or profile URL.
xstringX (Twitter) handle or profile URL.
emailstringContact email address.
githubstringGitHub username or profile URL.
youtubestringYouTube channel URL.
linkedinstringLinkedIn profile URL.
redditstringReddit username or profile URL.

getMetadata

Returns the full on-chain metadata for a given NFT ID.

solidity
function getMetadata(uint256 nftId) public view returns (Metadata memory);

Parameters

ParameterTypeDescription
nftIduint256The ID of the NFT to retrieve metadata for.

Returns

TypeDescription
MetadataThe complete metadata struct for the NFT. See Metadata Struct for member details.