You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
I am trying to deploy an endpoint on AWS Lambda that implements a web3 provider engine. I am trying to use a private key to sign transactions with Web3 and INFURA. Here is some of my code (private data redacted):
module.exports.handler = (event, context, callback) => { // lambda boilerplate
// get wallet from private key
const myWallet = Wallet.fromV3(
JSON.stringify({
address: '<ADDRESS>',
crypto: {
// crypto params
}),
'<PASSWORD>',
true
)
// console.log(web3)
const providerUrl = 'https://kovan.infura.io/<INFURA_TOKEN>'
const engine = new ProviderEngine()
engine.addProvider(new WalletSubprovider(myWallet, {}))
engine.addProvider(
new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl))
)
let web3 = new Web3(engine)
engine.start()
web3.eth.getBlockNumber((err, result) => {
callback(
null,
success({
message: 'Web3 is connected!',
block: result
})
)
})
Everything works fine when I run locally, but when I try to run it on AWS Lambda, I get timeout errors. I have pinpointed the issue to engine.start(). Is there a dependency with engine.start() on a specific Node version (Lambda runs 6.10)? Is there some sort of websocket or connection being opened that is not supported by Lambda?
The text was updated successfully, but these errors were encountered:
@rhlsthrm at some point we changed the default provider to fetch, maybe that was the issue. It was replaced with a polyfill.
additionally engine.start() now takes a callback that will catch the error.
Let me know if the latest version does not work on aws lambdas
I am trying to deploy an endpoint on AWS Lambda that implements a web3 provider engine. I am trying to use a private key to sign transactions with Web3 and INFURA. Here is some of my code (private data redacted):
Everything works fine when I run locally, but when I try to run it on AWS Lambda, I get timeout errors. I have pinpointed the issue to
engine.start()
. Is there a dependency withengine.start()
on a specific Node version (Lambda runs 6.10)? Is there some sort of websocket or connection being opened that is not supported by Lambda?The text was updated successfully, but these errors were encountered: