API Integration

Developer Integration Guide


Smart Contract Integration

WAGMI Setup

import { createConfig, http } from "wagmi";
import { mantleSepoliaTestnet } from "wagmi/chains";

export const config = createConfig({
  chains: [mantleSepoliaTestnet],
  transports: {
    [mantleSepoliaTestnet.id]: http("https://rpc.sepolia.mantle.xyz"),
  },
});

Contract Constants

const CONTRACTS = {
  GOLD_TOKEN: "0x787c8616d9b8Ccdca3B2b930183813828291dA9c",
  OWNAFARM_NFT: "0xC51601dde25775bA2740EE14D633FA54e12Ef6C7",
};

Read Contract

Write Contract


Backend API

Base Configuration

Endpoints

Authentication

Endpoint
Method
Description

/auth/nonce

GET

Get nonce for wallet

/auth/login

POST

Login with signature

Farmers

Endpoint
Method
Description

/farmers/register

POST

Register farmer

/farmers/documents/presign

POST

Get upload URLs

Crops (Investor)

Endpoint
Method
Description

/crops

GET

List user crops

/crops/:id

GET

Get crop details

/crops/sync

POST

Sync from blockchain

/crops/:id/water

POST

Water plant

Game

Endpoint
Method
Description

/user/profile

GET

Get profile

/leaderboard

GET

Get rankings

/marketplace/invoices

GET

Available invoices


Go Backend Integration

Ethereum Client

Read Contract

Event Listening


Error Handling

Contract Errors

API Errors

Code
Description

400

Bad request

401

Unauthorized

404

Not found

429

Rate limited

500

Server error


Next: Glossary

Last updated