Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@edgeandnode/contract-utils

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edgeandnode/contract-utils

Exposes contract utils to interact with The Graph Network contracts.

  • 2.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
261
increased by289.55%
Maintainers
0
Weekly downloads
 
Created
Source

@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

FAQs

Package last updated on 27 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc