Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ownafarm.xyz/llms.txt

Use this file to discover all available pages before exploring further.

GoldToken

Standard ERC-20 with minting capability.

Read functions

FunctionReturnsDescription
balanceOf(address)uint256GOLD balance
allowance(owner, spender)uint256Approved amount
totalSupply()uint256Total circulation
name()string”OwnaFarm Gold”
symbol()string”GOLD”
decimals()uint818

Write functions

FunctionAccessDescription
transfer(to, amount)PublicTransfer GOLD
approve(spender, amount)PublicApprove spender
transferFrom(from, to, amount)PublicDelegated transfer
mint(to, amount)OwnerMint new GOLD

GoldFaucet

Testnet token distribution.

Read functions

FunctionReturnsDescription
canClaim(address)boolClaim eligibility
timeUntilNextClaim(address)uint256Seconds until next claim
claimAmount()uint256GOLD per claim
cooldownTime()uint256Seconds between claims

Write functions

FunctionAccessDescription
claim()PublicClaim free GOLD
deposit(amount)PublicAdd GOLD to faucet
setClaimAmount(amount)AdminChange claim amount
setCooldownTime(seconds)AdminChange cooldown
withdraw(amount)AdminWithdraw GOLD

OwnaFarmNFT

Core invoice and investment contract.

Submit invoice

function submitInvoice(
    bytes32 offtakerId,
    uint128 targetFund,
    uint16 yieldBps,
    uint32 duration
) external returns (uint256 tokenId)
ParameterExampleDescription
offtakerId0x4f46…Buyer identifier hash
targetFund10000e1810,000 GOLD
yieldBps150015% yield
duration259200030 days

Invest

function invest(uint256 tokenId, uint128 amount) external
Requirements:
  • Invoice status is Approved
  • GOLD spending approved
  • Amount within target

Harvest

function harvest(uint256 investmentId) external
Requirements:
  • Investment exists
  • Not already claimed
  • Duration passed

Admin functions

FunctionAccessDescription
approveInvoice(tokenId)AdminApprove for investment
rejectInvoice(tokenId)AdminReject submission

View functions

FunctionDescription
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.
FunctionAccessDescription
setFarmNFT(address)AdminSet NFT contract (once)
depositYield(amount)AdminAdd yield reserve
withdrawYield(to, amount)FarmNFTPay investor yield
emergencyWithdraw(token, amount)OwnerEmergency recovery

Data structures

struct Invoice {
    address farmer;
    uint128 targetFund;
    uint128 fundedAmount;
    uint16 yieldBps;
    uint32 duration;
    uint32 createdAt;
    uint8 status;
    bytes32 offtakerId;
}

Common patterns

Approve before invest

await goldToken.approve(nftAddress, amount);
await ownaFarmNFT.invest(tokenId, amount);

Check harvest eligibility

const investment = await nft.getInvestment(investor, id);
const invoice = await nft.invoices(investment.tokenId);
const maturity = investment.investedAt + invoice.duration;
const canHarvest = Date.now() / 1000 >= maturity && !investment.claimed;

Error codes

ErrorCause
InsufficientBalanceNot enough GOLD
InsufficientAllowanceNeed to approve first
InvoiceNotApprovedWrong invoice status
AlreadyClaimedAlready harvested
NotMatureDuration not passed
ExceedsTargetInvestment too large