ABI Reference
Use these ABIs to interact with TAG IT smart contracts from your applications.
ProductRegistry ABI
The ProductRegistry contract is the core contract for registering and verifying products on the TAG IT Network. Below are the key functions and their ABI specifications.
registerProduct function
Registers a new product on the blockchain with its metadata and NFC tag identifier.
// Solidity Function Signature
function registerProduct(
bytes32 tagId,
string calldata productName,
string calldata serialNumber,
string calldata metadataURI
) external returns (uint256 productId)
Parameters:
tagId- Unique NFC tag identifier (32 bytes)productName- Human-readable product nameserialNumber- Manufacturer serial numbermetadataURI- IPFS or HTTP URI pointing to extended metadata
{
"name": "registerProduct",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [
{ "name": "tagId", "type": "bytes32" },
{ "name": "productName", "type": "string" },
{ "name": "serialNumber", "type": "string" },
{ "name": "metadataURI", "type": "string" }
],
"outputs": [
{ "name": "productId", "type": "uint256" }
]
}
verifyProduct function
Verifies the authenticity of a product by its tag ID. Returns the product details and verification status.
// Solidity Function Signature
function verifyProduct(
bytes32 tagId
) external view returns (
bool isAuthentic,
uint256 productId,
address currentOwner,
uint256 registrationTimestamp
)
Parameters:
tagId- The NFC tag identifier to verify
Returns:
isAuthentic- Whether the product is registered and validproductId- The unique product ID on-chaincurrentOwner- Address of the current product ownerregistrationTimestamp- Unix timestamp of product registration
{
"name": "verifyProduct",
"type": "function",
"stateMutability": "view",
"inputs": [
{ "name": "tagId", "type": "bytes32" }
],
"outputs": [
{ "name": "isAuthentic", "type": "bool" },
{ "name": "productId", "type": "uint256" },
{ "name": "currentOwner", "type": "address" },
{ "name": "registrationTimestamp", "type": "uint256" }
]
}
getProduct function
Retrieves full product details including metadata URI and transfer history count.
// Solidity Function Signature
function getProduct(
uint256 productId
) external view returns (
bytes32 tagId,
string memory productName,
string memory serialNumber,
string memory metadataURI,
address currentOwner,
uint256 transferCount,
bool isActive
)
{
"name": "getProduct",
"type": "function",
"stateMutability": "view",
"inputs": [
{ "name": "productId", "type": "uint256" }
],
"outputs": [
{ "name": "tagId", "type": "bytes32" },
{ "name": "productName", "type": "string" },
{ "name": "serialNumber", "type": "string" },
{ "name": "metadataURI", "type": "string" },
{ "name": "currentOwner", "type": "address" },
{ "name": "transferCount", "type": "uint256" },
{ "name": "isActive", "type": "bool" }
]
}
TransferManager ABI
The TransferManager contract handles secure ownership transfers between parties with optional escrow functionality.
initiateTransfer function
Initiates a product ownership transfer to a new owner. The transfer must be completed by the recipient.
// Solidity Function Signature
function initiateTransfer(
uint256 productId,
address newOwner,
uint256 escrowAmount,
uint256 expirationTime
) external payable returns (bytes32 transferId)
Parameters:
productId- ID of the product to transfernewOwner- Address of the intended recipientescrowAmount- Optional escrow amount in wei (0 for no escrow)expirationTime- Unix timestamp when the transfer offer expires
{
"name": "initiateTransfer",
"type": "function",
"stateMutability": "payable",
"inputs": [
{ "name": "productId", "type": "uint256" },
{ "name": "newOwner", "type": "address" },
{ "name": "escrowAmount", "type": "uint256" },
{ "name": "expirationTime", "type": "uint256" }
],
"outputs": [
{ "name": "transferId", "type": "bytes32" }
]
}
completeTransfer function
Completes a pending transfer. Must be called by the designated new owner.
// Solidity Function Signature
function completeTransfer(
bytes32 transferId,
bytes calldata signature
) external returns (bool success)
Parameters:
transferId- Unique transfer identifier returned by initiateTransfersignature- EIP-712 signature from the new owner confirming receipt
{
"name": "completeTransfer",
"type": "function",
"stateMutability": "nonpayable",
"inputs": [
{ "name": "transferId", "type": "bytes32" },
{ "name": "signature", "type": "bytes" }
],
"outputs": [
{ "name": "success", "type": "bool" }
]
}
Contract Events
TAG IT smart contracts emit events that can be monitored to track product registrations and transfers in real-time.
ProductRegistered
Emitted when a new product is successfully registered on the network.
event ProductRegistered(
uint256 indexed productId,
bytes32 indexed tagId,
address indexed owner,
string productName,
uint256 timestamp
);
{
"name": "ProductRegistered",
"type": "event",
"inputs": [
{ "name": "productId", "type": "uint256", "indexed": true },
{ "name": "tagId", "type": "bytes32", "indexed": true },
{ "name": "owner", "type": "address", "indexed": true },
{ "name": "productName", "type": "string", "indexed": false },
{ "name": "timestamp", "type": "uint256", "indexed": false }
]
}
TransferInitiated
Emitted when a product transfer is initiated by the current owner.
event TransferInitiated(
bytes32 indexed transferId,
uint256 indexed productId,
address indexed fromOwner,
address toOwner,
uint256 escrowAmount,
uint256 expirationTime
);
{
"name": "TransferInitiated",
"type": "event",
"inputs": [
{ "name": "transferId", "type": "bytes32", "indexed": true },
{ "name": "productId", "type": "uint256", "indexed": true },
{ "name": "fromOwner", "type": "address", "indexed": true },
{ "name": "toOwner", "type": "address", "indexed": false },
{ "name": "escrowAmount", "type": "uint256", "indexed": false },
{ "name": "expirationTime", "type": "uint256", "indexed": false }
]
}
TransferCompleted
Emitted when a product transfer is successfully completed.
event TransferCompleted(
bytes32 indexed transferId,
uint256 indexed productId,
address indexed newOwner,
uint256 timestamp
);
{
"name": "TransferCompleted",
"type": "event",
"inputs": [
{ "name": "transferId", "type": "bytes32", "indexed": true },
{ "name": "productId", "type": "uint256", "indexed": true },
{ "name": "newOwner", "type": "address", "indexed": true },
{ "name": "timestamp", "type": "uint256", "indexed": false }
]
}
Using ABIs with ethers.js
Here's how to use the TAG IT ABIs with ethers.js to interact with the smart contracts:
import { ethers } from 'ethers';
import ProductRegistryABI from './abis/ProductRegistry.json';
import TransferManagerABI from './abis/TransferManager.json';
// Contract addresses (Polygon Mainnet)
const PRODUCT_REGISTRY_ADDRESS = '0x1234567890abcdef1234567890abcdef12345678';
const TRANSFER_MANAGER_ADDRESS = '0xabcdef1234567890abcdef1234567890abcdef12';
// Connect to provider
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
// Initialize contract instances
const productRegistry = new ethers.Contract(
PRODUCT_REGISTRY_ADDRESS,
ProductRegistryABI,
signer
);
const transferManager = new ethers.Contract(
TRANSFER_MANAGER_ADDRESS,
TransferManagerABI,
signer
);
// Example: Register a new product
async function registerProduct(tagId, name, serial, metadataURI) {
const tagIdBytes = ethers.encodeBytes32String(tagId);
const tx = await productRegistry.registerProduct(
tagIdBytes,
name,
serial,
metadataURI
);
const receipt = await tx.wait();
console.log('Product registered:', receipt.hash);
return receipt;
}
// Example: Verify a product
async function verifyProduct(tagId) {
const tagIdBytes = ethers.encodeBytes32String(tagId);
const result = await productRegistry.verifyProduct(tagIdBytes);
return {
isAuthentic: result.isAuthentic,
productId: result.productId.toString(),
currentOwner: result.currentOwner,
registrationTimestamp: new Date(Number(result.registrationTimestamp) * 1000)
};
}
// Example: Listen for ProductRegistered events
productRegistry.on('ProductRegistered', (productId, tagId, owner, productName, timestamp) => {
console.log('New product registered:', {
productId: productId.toString(),
tagId: tagId,
owner: owner,
productName: productName,
timestamp: new Date(Number(timestamp) * 1000)
});
});
When using ethers.js v6, use ethers.BrowserProvider instead of the deprecated ethers.providers.Web3Provider.
Download Full ABIs
Download the complete ABI JSON files for integration into your projects:
- ProductRegistry.json - Full ProductRegistry contract ABI
- TransferManager.json - Full TransferManager contract ABI
- TagItToken.json - TAG IT ERC-20 token ABI
- all-contracts.zip - All ABIs in a single archive
These ABIs are for contract version 2.0.0. Always verify you're using the correct ABI version for the deployed contracts. Check the Contract Addresses page for version information.