Blockchain Integration

ERC-3643 on Polygon — Identity, Compliance, Security Tokens

Serviceblockchain-svc :8082Go / Fibergo-ethereumOfficial TREXFactoryONCHAINID

Official ERC-3643 T-REX Suite — Polygon Amoy (Chain 80002)

Deployed own TREXFactory stack (not Tokeny's shared factory). Single-transaction deployment of 6 upgradeable beacon proxy contracts per token. ONCHAINID-based identity with signed KYC claims.

TREXFactory0xdD82e41585A34750B93f4237aBaB2F5c4305B49F
IdFactory0x35eCf826e4EEBC909d8274C7579fA96185EaeC61
ClaimIssuer0x2cd28d69ae53c7a4f4d9da8f0b4b056e345ca97c
ImplementationAuthority0x1EAa6562063d3F84Fdc4c467af0D81adAE612606
DAGRI Token (first)0x63Bb4bb32a4C696863562323353549f9CDE225F4
Deployer0x28a002Cff880372987c85e3505542e770f3fA3E6

6

Contracts per token

1

Deploy transactions

Beacon

Proxy type

Complete lifecycle from token creation to investor trading, using official ERC-3643 T-REX with ONCHAINID claim-based identity verification.

Token Deployment → Investor Onboarding → Settlement

  Admin                    platform-api          blockchain-svc         Polygon Amoy
    │                          │                      │                      │
    │── Create token (draft) ──▶│                      │                      │
    │                          │                      │                      │
    │── Deploy token ──────────▶│                      │                      │
    │                          │── POST /deploy ──────▶│                      │
    │                          │                      │── TREXFactory         │
    │                          │                      │   .deployTREXSuite() ▶│
    │                          │                      │◀─ 6 contracts ────────│
    │                          │                      │── addModule() ×N ────▶│
    │                          │◀─ 6 addresses ───────│                      │
    │                          │                      │                      │
  Investor                     │                      │                      │
    │── Submit KYC ────────────▶│                      │                      │
    │   (Sumsub WebSDK)        │                      │                      │
    │                          │◀─ webhook GREEN ─────│  Sumsub              │
    │                          │                      │                      │
    │                          │── identity/deploy ───▶│                      │
    │                          │                      │── Node.js bridge ────▶│
    │                          │                      │   createIdentity()   │
    │                          │                      │◀─ ONCHAINID addr ────│
    │                          │                      │── addClaim(KYC) ─────▶│
    │                          │                      │── registerIdentity() ▶│
    │                          │                      │                      │
    │                          │── mint ──────────────▶│                      │
    │                          │                      │── Token.mint() ──────▶│
    │                          │                      │                      │
  Trading                      │                      │                      │
    │── Place order ───────────▶│  trading-server      │                      │
    │                          │── match ──────────────│                      │
    │                          │── settle ─────────────▶│                      │
    │                          │                      │── forcedTransfer() ──▶│
    │                          │◀─ tx_hash ────────────│                      │

Gas Costs Per Operation (Polygon Amoy)

OperationGasMATIC (30 gwei)USD ($0.40)
deployTREXSuite (6 contracts)3,925K0.118$0.047
addModule (per module)39K0.001$0.0005
createIdentity (ONCHAINID)458K0.014$0.005
addClaim (KYC)~100K0.003$0.001
registerIdentity (per token)80K0.002$0.001
mint~150K0.005$0.002
forcedTransfer (settlement)~100K0.003$0.001
setAddressFrozen~40K0.001$0.0005
Year 1 estimated total gas cost for 42 tokens + 1,000 investors + 100 trades/day = ~$60. Polygon gas is not a cost concern.

blockchain-svc is the sole interface to the Polygon chain. Neither platform-api nor trading-server have any go-ethereum dependency. All chain interactions are HTTP calls to blockchain-svc.

Service Boundaries

  platform-api:8081         trading-server:8080        blockchain-svc:8082       Polygon
    │                            │                          │                      │
    │ (token deploy,             │                          │                      │
    │  identity registration,    │                          │                      │
    │  minting)                  │                          │                      │
    │───── HTTP POST ───────────────────────────────────────▶│                      │
    │                            │                          │── Contract calls ────▶│
    │                            │                          │◀─ TX receipts ────────│
    │                            │                          │                      │
    │                            │ (settlement transfers)   │                      │
    │                            │───── HTTP POST ──────────▶│                      │
    │                            │                          │── forcedTransfer ────▶│
    │                            │◀──── {tx_hash} ──────────│                      │
    │                            │                          │                      │
    │                            │                          │── Event Indexer ──────│
    │                            │                          │   (30s polling)       │
    │                            │                          │◀─ FilterLogs ─────────│
    │                            │                          │── INSERT events ──────▶DB
blockchain-svc loads 3 ABIs at startup: SecurityToken.json, IdentityRegistry.json, Compliance.json
Single deployer wallet controls all contract interactions (agent role)
Gas limit: 3,000,000 for deployments, 300,000 for function calls
waitMined polls every 3 seconds with 3-minute timeout
All gas costs recorded asynchronously in gas_transactions table

Three contracts deployed per token. ERC-3643 is the standard for regulated security tokens with built-in identity verification and transfer compliance.

IdentityRegistry

Maps investor addresses to verified identities with country codes.

Key Functionssolidity
registerIdentity(address investor, uint16 countryCode)
removeIdentity(address investor)
isVerified(address investor) → bool
addAgent(address agent)  // grants registration permissions
Events: IdentityRegistered(address, uint16), IdentityRemoved(address)

Compliance

Enforces transfer rules. Linked to IdentityRegistry at construction.

Key Functionssolidity
constructor(address identityRegistry)
canTransfer(address from, address to) → bool
// Checks both sender and receiver are verified in IR

SecurityToken

ERC-20 compatible with compliance-checked transfers. Agent role for platform operations.

Key Functionssolidity
constructor(string name, string symbol, uint8 decimals,
            address identityRegistry, address compliance)
mint(address to, uint256 amount)           // agent only
forcedTransfer(address from, address to,
               uint256 amount)             // agent only
setAddressFrozen(address target, bool frozen)
pause() / unpause()
canTransferTokens(address from, address to) → bool
Events: Transfer(address, address, uint256), TokensMinted(address, uint256), TokensBurned(address, uint256), AddressFrozen(address, bool)

Token deployment creates 3 contracts and grants agent roles in 5 sequential transactions. All transactions are waited for mining before proceeding.

Deploy Sequence (5 TXs)

  blockchain-svc                                          Polygon
    │                                                        │
    │─── TX1: Deploy IdentityRegistry ──────────────────────▶│
    │    (no constructor args)                                │
    │◀── receipt (IR address) ───────────────────────────────│
    │    gas recorded: token_deploy_ir                        │
    │                                                        │
    │─── TX2: Deploy Compliance(IR address) ────────────────▶│
    │◀── receipt (Compliance address) ───────────────────────│
    │    gas recorded: token_deploy_compliance                │
    │                                                        │
    │─── TX3: Deploy SecurityToken(name, symbol, decimals,  │
    │         IR address, Compliance address) ───────────────▶│
    │◀── receipt (Token address) ────────────────────────────│
    │    gas recorded: token_deploy_token                     │
    │                                                        │
    │─── TX4: IR.addAgent(deployer address) ────────────────▶│
    │◀── receipt ────────────────────────────────────────────│
    │    gas recorded: token_deploy_add_agent                 │
    │                                                        │
    │─── TX5: Token.addAgent(deployer address) ─────────────▶│
    │◀── receipt ────────────────────────────────────────────│
    │    gas recorded: token_deploy_add_agent                 │

Gas Estimates (per TX)

TX1: IR

~2.5M

TX2: Compliance

~1.5M

TX3: Token

~3M

TX4: addAgent

~50K

TX5: addAgent

~50K

POST/api/v1/deploy(blockchain-svc)Deploy ERC-3643 suite
Deploy Request Bodyjson
{
  "name": "DAGRI Token",
  "symbol": "DAGRI",
  "decimals": 18,
  "total_supply": 10000000,
  "token_id": "uuid-v7-here"
}
Deploy Responsejson
{
  "identity_registry_addr": "0x...",
  "compliance_addr": "0x...",
  "token_addr": "0x...",
  "ir_deploy_tx_hash": "0x...",
  "comp_deploy_tx_hash": "0x...",
  "token_deploy_tx_hash": "0x...",
  "chain_id": 31337
}
The deployer address becomes the sole agent on both IR and Token contracts. This is required for registerIdentity and forcedTransfer operations.
See also:Cross-Portal Workflows (settlement, token issuance)