Skip to main content

Backend API Documentation

Contract Integration​

Contract Address​

  • Mainnet: 0x... (To be deployed)
  • Testnet: 0x... (To be deployed)

ABI Functions​

Minting Functions​

function safeMint(
address to,
string calldata uri,
uint64 startTime,
uint64 endTime
) external onlyRole(MINTER_ROLE)

License Management​

function updateLicenseMetadata(
uint256 tokenId,
string calldata newUri
) external onlyRole(MINTER_ROLE)

function revoke(uint256 tokenId) external onlyRole(MINTER_ROLE)

function reassign(
uint256 tokenId,
address newOwner,
string calldata reason
) external onlyRole(MINTER_ROLE)

Status Functions​

function isTokenExpired(uint256 tokenId) public view returns (bool)
function startTime(uint256 tokenId) external view returns (uint64)
function endTime(uint256 tokenId) external view returns (uint64)
function locked(uint256 tokenId) external view returns (bool)

Events to Monitor​

event LicenseIssued(
address indexed to,
uint256 indexed tokenId,
uint64 startTime,
uint64 endTime,
string uri
);

event LicenseUpdated(
uint256 indexed tokenId,
bool invalid,
uint64 expiresAt,
string reason
);

event LicenseReassigned(
uint256 indexed tokenId,
address indexed from,
address indexed to,
string reason
);

Backend Integration​

Required Roles​

  • MINTER_ROLE: For issuing and managing licenses
  • PAUSER_ROLE: For emergency pause functionality
  • UPGRADER_ROLE: For contract upgrades

Environment Variables​

CONTRACT_ADDRESS=0x...
PRIVATE_KEY=your_private_key
RPC_URL=https://api.avax.network/ext/bc/C/rpc

Example Usage​

// Issue a new license
await contract.safeMint(userAddress, metadataURI, startTimestamp, endTimestamp);

// Check if license is expired
const isExpired = await contract.isTokenExpired(tokenId);

// Update license metadata
await contract.updateLicenseMetadata(tokenId, newURI);