@edgeandnode/contract-utils
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

@edgeandnode/contract-utils

Exposes contract utils to interact with The Graph Network contracts.

Usage

# install the dependency

## pnpm
pnpm add @edgeandnode/contract-utils
## yarn
yarn add @edgeandnode/contract-utils
## bun
bun add @edgeandnode/contract-utils

Retrieve the contract address of a Graph Network contract on the specified network

import { resolveContractAddress } from '@edgeandnode/contract-utils'

// retrieve correct GNS address for arbitrum
const L2GNSAddress = resolveContractAddress({ network: 42161, contract: 'GNS' })
// retrieve correct GraphToken address for sepolia
const SepoliaGraphTokenAddress = resolveContractAddress({
  network: 11155111,
  contract: 'GraphToken',
})

Call the mintSignal L2GNS contract function from the generated actions.

import { createClient } from 'viem'
import { createConfig, http } from 'wagmi'
import { arbitrum, arbitrumSepolia, mainnet, sepolia } from 'wagmi/chains'
import { coinbaseWallet, injected, safe, walletConnect } from 'wagmi/connectors'

import { buildConfig, writeL2GnsMintSignal } from '@edgeandnode/contract-utils'

async function mint() {
  const config = createConfig({
    chains: [arbitrum, arbitrumSepolia, mainnet, sepolia],
    ssr,
    client({ chain }) {
      return createClient({ chain, transport: http() })
    },
    connectors: [
      coinbaseWallet({ appName: 'The Graph' }),
      injected(),
      safe({ allowedDomains: [/app.safe.global$/] }),
      walletConnect({
        projectId: 'WALLETCONNECT_PROJECT_ID',
        metadata: {
          name: 'The Graph',
          description: 'The Graph Network suite of apps wallet integration',
          url: 'https://thegraph.com',
          icons: [''],
        },
        qrModalOptions: {
          themeMode: 'dark',
        },
      }),
    ],
  })

  const mintTx = await writeL2GnsMintSignal(config, {
    account: `0x`,
    args: [0n, 0n, 0n],
  })
}

Generating wagmi types

# required a `.env.local` file with env vars (see below)
pnpm generate
# or
pnpm wagmi generate

Env vars (used to run wagmi generate)

  • ARBISCAN_KEY -> api key for reading contract ABIs from arbiscan.io
  • ETHERSCAN_KEY -> api key for reading contract ABIs from etherscan.io

References

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.2-build-improvements-1729527394625-be2ef58067df30b2efe4a77489d8c80ecbdc1f890build-improvements
2.1.1-update-dependencies-1728401164696-7ee3c07ef999717a726698c227c226b443fd47270update-dependencies
2.1.0-feat-contract-utils--updates-1724087445674-376d268446efb5bc7ac9cc33ad9183da562bf3190feat-contract-utils--updates
2.0.0-feat-contract-utils-1709648445643-f5b623678a161b4125b5af04bc9624a12064973c0feat-contract-utils
2.1.22latest

Version History

VersionDownloads (Last 7 Days)Published
2.1.22
2.1.2-build-improvements-1729527394625-be2ef58067df30b2efe4a77489d8c80ecbdc1f890
2.1.2-build-improvements-1729296545889-8877574e9a7e61e3b45831ff19b0c668903c8bf60
2.1.2-build-improvements-1729293365357-c294e5d42d8aab1466c3270b5adb7e829394e7f80
2.1.2-build-improvements-1729291796266-7dcf53ef590d8bc9046e701898e8fda78c52c9af0
2.1.2-build-improvements-1729289175413-44698d9dc62e095f05173f192a1687854e803f1d0
2.1.10
2.1.1-update-dependencies-1728401164696-7ee3c07ef999717a726698c227c226b443fd47270
2.1.00
2.1.0-feat-contract-utils--updates-1724087445674-376d268446efb5bc7ac9cc33ad9183da562bf3190
2.0.00
2.0.0-feat-contract-utils-1709648445643-f5b623678a161b4125b5af04bc9624a12064973c0
2.0.0-feat-contract-utils-1709163629393-3dce0719217ade7283688472a55c151fc1cfb9b20
2.0.0-feat-contract-utils-1709077692572-78ef4f2214fc2e41c4fd0d9d7bfe28d46dbfdfef1
2.0.0-feat-contract-utils-1709075232822-55e7386ce60881a26f5536779341760de86d80470
2.0.0-feat-contract-utils-1709073259404-d984c45b169d441dfe6015feffecafb59e8807ca0
2.0.0-feat-contract-utils-1709070231516-cadfcbda70cfecf06db631015b3af9009e671d720

Package Sidebar

Install

npm i @edgeandnode/contract-utils

Weekly Downloads

3

Version

2.1.2

License

UNLICENSED

Unpacked Size

24.8 MB

Total Files

12

Last publish

Collaborators

  • hayderkg
  • a3k5
  • mitchhs12
  • andras_en
  • migueldeelias
  • pcarranzav_edgeandnode
  • lutter
  • edge-and-node
  • leoyvens
  • lnsd
  • neysofu
  • nasmr
  • adam-en
  • benface
  • fordn
  • theodus
  • jannispohlmann
  • dnfodjo
  • iain_mccown
  • that3percent
  • cmwhited
  • schmidsi