HenriableVehicleNFT
Inherits: ERC721, Ownable
Title: Henriable vehicle-title NFT.
Author: Obiaraije Henry
An ERC721 that represents the title deed of one physical asset. The platform mints it to itself once an investment is fully funded and transfers it to the rider when the hire purchase is paid in full. The token is a standard, transferable ERC721 after the rider receives it.
Kept as its own contract (not inherited by {Henriable}) so the platform’s business logic stays under the EIP-170 code-size limit. Minting is gated by a single {minter} address, which the owning deployer sets to the {Henriable} address during deployment; the deployer keeps admin control of the collection.
State Variables
minter
The only address allowed to mint titles (the {Henriable} platform).
address(0) means no address can mint until the owner sets it.
address internal minter
nextTokenId
Id that will be assigned to the next minted title.
Ids start at 1 so 0 keeps meaning “no title”, matching the platform.
uint256 internal nextTokenId
Functions
constructor
Deploys the collection with its name and symbol.
constructor(address initialOwner) ERC721("Henriable Vehicle Title", "HVT") Ownable(initialOwner);
Parameters
| Name | Type | Description |
|---|---|---|
initialOwner | address | The address that owns the collection and may set the minter. |
onlyMinter
Restricts a function to the configured {minter}.
Reverts with {HVehicleNftUnauthorizedMinter} when the caller is not the minter.
modifier onlyMinter() ;
setMinter
Sets the address allowed to mint titles, typically the platform.
Only the collection owner may call this. Pass address(0) to disable minting. States updated: {minter}.
function setMinter(address newMinter) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
newMinter | address | The address allowed to mint, or address(0) to disable minting. |
mint
Mints the next title to an address.
Only the {minter} may call this. Ids are assigned sequentially from 1. States updated: {nextTokenId}.
function mint(address to) external onlyMinter returns (uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | The address that will own the newly minted title. |
Returns
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The id of the newly minted title. |
tokenURI
Returns the token’s metadata as an on-chain base64 data URI.
ERC721 metadata JSON with an inline base64 SVG image, so titles render in Etherscan, wallets and marketplaces with no off-chain hosting. The owner on the card is read live, so it updates when the platform transfers the deed. Reverts for a non-existent token (via {_requireOwned}).
function tokenURI(uint256 tokenId) public view override returns (string memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The title’s token id. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | A data:application/json;base64,... URI. |
_renderSvg
Renders the title card as an SVG.
function _renderSvg(uint256 tokenId, address owner, string memory asset, address rider)
internal
pure
returns (string memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The title’s token id. |
owner | address | The current owner, shown on the card. |
asset | string | The asset name (empty when unknown). |
rider | address | The hired rider (address(0) when unknown), shown on the card. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The SVG markup. |
_titleInfo
Reads the asset name and rider from the platform (the minter).
Returns zero values when the minter is unset or is not a contract that answers, so metadata degrades gracefully instead of reverting.
function _titleInfo(uint256 tokenId) internal view returns (bytes32 assetName, address rider);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The title’s token id. |
Returns
| Name | Type | Description |
|---|---|---|
assetName | bytes32 | The bytes32 asset name, or bytes32(0). |
rider | address | The rider, or address(0). |
_bytes32ToString
Decodes a bytes32 asset name into a trimmed ASCII string.
function _bytes32ToString(bytes32 value) internal pure returns (string memory);
Parameters
| Name | Type | Description |
|---|---|---|
value | bytes32 | The bytes32 to decode. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The decoded string (up to the first zero byte). |
getMinter
Returns the address allowed to mint titles.
function getMinter() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The configured minter, or address(0) when unset. |
getNextTokenId
Returns the id that will be assigned to the next minted title.
function getNextTokenId() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The next token id. |