GoldToken
Standard ERC-20 with minting capability.Read functions
| Function | Returns | Description |
|---|---|---|
balanceOf(address) | uint256 | GOLD balance |
allowance(owner, spender) | uint256 | Approved amount |
totalSupply() | uint256 | Total circulation |
name() | string | ”OwnaFarm Gold” |
symbol() | string | ”GOLD” |
decimals() | uint8 | 18 |
Write functions
| Function | Access | Description |
|---|---|---|
transfer(to, amount) | Public | Transfer GOLD |
approve(spender, amount) | Public | Approve spender |
transferFrom(from, to, amount) | Public | Delegated transfer |
mint(to, amount) | Owner | Mint new GOLD |
GoldFaucet
Testnet token distribution.Read functions
| Function | Returns | Description |
|---|---|---|
canClaim(address) | bool | Claim eligibility |
timeUntilNextClaim(address) | uint256 | Seconds until next claim |
claimAmount() | uint256 | GOLD per claim |
cooldownTime() | uint256 | Seconds between claims |
Write functions
| Function | Access | Description |
|---|---|---|
claim() | Public | Claim free GOLD |
deposit(amount) | Public | Add GOLD to faucet |
setClaimAmount(amount) | Admin | Change claim amount |
setCooldownTime(seconds) | Admin | Change cooldown |
withdraw(amount) | Admin | Withdraw GOLD |
OwnaFarmNFT
Core invoice and investment contract.Submit invoice
| Parameter | Example | Description |
|---|---|---|
| offtakerId | 0x4f46… | Buyer identifier hash |
| targetFund | 10000e18 | 10,000 GOLD |
| yieldBps | 1500 | 15% yield |
| duration | 2592000 | 30 days |
Invest
- Invoice status is Approved
- GOLD spending approved
- Amount within target
Harvest
- Investment exists
- Not already claimed
- Duration passed
Admin functions
| Function | Access | Description |
|---|---|---|
approveInvoice(tokenId) | Admin | Approve for investment |
rejectInvoice(tokenId) | Admin | Reject submission |
View functions
| Function | Description |
|---|---|
invoices(tokenId) | Get invoice details |
getInvestment(investor, id) | Get investment details |
investmentCount(investor) | Count investments |
getPendingInvoices(offset, limit) | List pending |
getAvailableInvoices(offset, limit) | List available |
OwnaFarmVault
Yield reserve management.| Function | Access | Description |
|---|---|---|
setFarmNFT(address) | Admin | Set NFT contract (once) |
depositYield(amount) | Admin | Add yield reserve |
withdrawYield(to, amount) | FarmNFT | Pay investor yield |
emergencyWithdraw(token, amount) | Owner | Emergency recovery |
Data structures
Common patterns
Approve before invest
Check harvest eligibility
Error codes
| Error | Cause |
|---|---|
| InsufficientBalance | Not enough GOLD |
| InsufficientAllowance | Need to approve first |
| InvoiceNotApproved | Wrong invoice status |
| AlreadyClaimed | Already harvested |
| NotMature | Duration not passed |
| ExceedsTarget | Investment too large |