Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

433
Visualizações
abi.map not a function error trying to connect to uniswap

I'm new to working with blockchain and I'm having a problem trying to get the contract from Uniswap. I've been following their docs on V3 but I can't get past this "abi.map is not a function" error. When I output the ABI to the console, it looks like I get the ABI back correctly but when I try to use it to initialize the contract I get this error.

import { ethers } from 'ethers'
const ABI = require('@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json')
console.log(ABI)

const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/Your Address Here;p')
const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8'
const poolContract = new ethers.Contract(poolAddress, ABI, provider)

interface Immutables {
  factory: string 
  token0: string
  token1: string 
  fee: number
  tickSpacing: number
  maxLiquidityPerTick: number
}

async function getPoolImmutables() {
  const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([
    poolContract.factory(),
    poolContract.token0(),
    poolContract.token1(),
    poolContract.fee(),
    poolContract.tickSpacing(),
    poolContract.maxLiquidityPerTick(),
  ])

  const immutables: Immutables = {
    factory,
    token0,
    token1,
    fee,
    tickSpacing,
    maxLiquidityPerTick,
  }
  return immutables
}

getPoolImmutables().then((result) => {
  console.log(result)
})

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This error will go away if you delete everything in the abi up to the first square bracket after "abi". So for IUniswapV3Pool.json, instead of:

{
  "_format": "hh-sol-artifact-1",
  "contractName": "IUniswapV3Pool",
  "sourceName": "contracts/interfaces/IUniswapV3Pool.sol",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
...

It should be:

[
    {
      "anonymous": false,
      "inputs": [

And don't forget to delete everything up to the last square bracket at the end of the file as well.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda