英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论