Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use human-readable ABI format in smart contract client #118

Open
NikolasHaimerl opened this issue Mar 11, 2025 · 0 comments
Open

Use human-readable ABI format in smart contract client #118

NikolasHaimerl opened this issue Mar 11, 2025 · 0 comments
Assignees

Comments

@NikolasHaimerl
Copy link
Contributor

NikolasHaimerl commented Mar 11, 2025

Use human-readable ABI format in smart contract client

Description

Following the implementation of smart-contract-based mapping of MinerID to IndexProviderPeerID in #117 , we should improve the developer experience by switching to a human-readable ABI format in the smart contract client.

This issue originated from the discussion in CheckerNetwork/roadmap#250 (comment), where it was noted that:

  1. The current implementation uses a standard JSON ABI format which lacks type inference
  2. This results in no autocomplete or type checking when working with the contract
  3. Ethers.js supports a human-readable ABI format that would improve developer experience

While we decided to stick with ethers.js for now instead of switching to viem (to minimize changes in the time-pressing initial implementation), updating to a human-readable ABI format would be a good improvement for maintainability.

Current ABI format

const contractABI = [
  {
    inputs: [
      {
        internalType: 'uint64',
        name: 'minerID',
        type: 'uint64'
      }
    ],
    name: 'getPeerData',
    outputs: [
      {
        components: [
          {
            internalType: 'string',
            name: 'peerID',
            type: 'string'
          },
          {
            internalType: 'bytes',
            name: 'signature',
            type: 'bytes'
          }
        ],
        internalType: 'struct MinerPeerIDMapping.PeerData',
        name: '',
        type: 'tuple'
      }
    ],
    stateMutability: 'view',
    type: 'function'
  }
]

Proposed human-readable ABI format

const contractABI = [
  "function getPeerData(uint64 minerID) view returns (tuple(string peerID, bytes signature))"
]

Related issues/PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📥 next
Development

No branches or pull requests

1 participant