调用Lambda中的Polygon Infura API不起作用。

huangapple go评论41阅读模式
英文:

call polygon infura api from lambda not working

问题

我们正在尝试通过OpenZeppelin Defender和Infura API实现无Gas铸币。

如果在本地运行,它将正常工作。但如果在AWS Lambda上运行,现在无法正常工作。

通过我的调查,这个请求(HTTPSProvider.getTransactionCount)无法获得任何响应。


import {
    Contract,
    providers,
    Wallet,
    Signer,
    BigNumberish,
    BytesLike
} from 'ethers';
import Web3 from 'web3';
import { AccessController, contracts } from './typechain-types';
import '@ethersproject/shims';

export const web3: Web3 = new Web3(
    new Web3.providers.HttpProvider(process.env.NODE_URL || '')
);

export const HTTPSProvider = new providers.JsonRpcProvider(
    process.env.NODE_URL || ''
);

const nonce: BigNumberish = await HTTPSProvider.getTransactionCount(
        await wallet.getAddress()
        
    );

NODE_URL在这里

https://polygon-mainnet.infura.io/v3/xxxxxxxxdddddddggggg

有人知道这个原因吗?

在Lambda上无Gas铸币正常工作

英文:

We are trying to implement gasless mint through openzepplin defender and infura API.

If it ran at local, it would work fine.
But if it ran at AWS lambda, it does not work now.

Through my investigating, this request(HTTPSProvider.getTransactionCount) can not get any responces.


import {
    Contract,
    providers,
    Wallet,
    Signer,
    BigNumberish,
    BytesLike
} from 'ethers';
import Web3 from 'web3';
import { AccessController, contracts } from './typechain-types';
import '@ethersproject/shims';

export const web3: Web3 = new Web3(
    new Web3.providers.HttpProvider(process.env.NODE_URL || '')
);

export const HTTPSProvider = new providers.JsonRpcProvider(
    process.env.NODE_URL || ''
);

const nonce: BigNumberish = await HTTPSProvider.getTransactionCount(
        await wallet.getAddress()
        
    );

NODE_URL is here

https://polygon-mainnet.infura.io/v3/xxxxxxxxdddddddggggg

Does anyone know this reason?

gasless mint works fine at lambda

答案1

得分: 0

我能解决。
Lambda在默认设置下无法访问互联网上的外部URL的原因。
我放了一个带有NAT网关的子网。

英文:

I could resolve.
The reason why Lambda can not access external URL over the internet under default setting.
I put a subnet with nat gateway.

huangapple
  • 本文由 发表于 2023年4月17日 15:26:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定