0

I'm getting following error message when trying to unlock account on AWS Lambda:

Error: Node error: {"code":-32601,"message":"The method personal_unlockAccount does not exist/is not available"}
    at Function.validate (/var/task/node_modules/web3-providers/dist/web3-providers.cjs.js:111:18)
    at HttpProvider._callee$ (/var/task/node_modules/web3-providers/dist/web3-providers.cjs.js:674:61)
    at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/var/task/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/var/task/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
'use strict';

const AWS = require('aws-sdk');
AWS.config.update({region: 'ap-northeast-1'});
const documentClient = new AWS.DynamoDB.DocumentClient();

const Web3 = require('web3');  
const web3 = new Web3(new Web3.providers.HttpProvider(process.env['INFURA_ENDPOINT']));
const abiSource = require('./lib/myToken.json');
const abi = abiSource.abi;
const contractAddress = process.env['CONTRACT_ADDRESS'];
const myToken = web3.eth.Contract(abi, contractAddress);

.
.
.

exports.handler = async (event, context) => {
  event = event.body || event;
  const senderAddress = event.sender_address;
  const privateKey = event.private_key;
  try{
    await web3.eth.personal.unlockAccount(senderAddress, privateKey, 600);
  }catch(error){
    console.log(error);
    return getResponse(200, 'Internal server error');
  }

  .
  .
  .
};

My contract is deployed on Ropsten network, Although I have some code for processing transaction in following, which raises same error. Any ideas how to fix that / what the cause of error is?

Node version: 8.0 Web3: 1.0.0-beta50

Thanks in advance!

  • 1
    Node version: 8.0 is a very insufficient piece of information. What type of node is this (e.g., Parity, Geth, etc)? – goodvibration Mar 24 at 9:22
  • In any case, you probably forgot to enable the personal API when you started that node. For example, in Parity, see --jsonrpc-apis or --ws-apis or --ipc-apis (choose the one corresponding to your connection type, most likely the first one I suppose). – goodvibration Mar 24 at 9:25
  • I also recommend that you use web3.js v1.0.0-beta34 (or at most 37). There have been various issues in later versions AFAIK. – goodvibration Mar 24 at 9:27
  • I mean Node.js 8.x as AWS Lambda execution environment, and Infura.io for Ethereum client. For now I've downgraded to v1.0.0-beta34, but the consequence remain same. Let me look it up 2nd comment and figure it out, thanks! – taruya Mar 24 at 13:42
  • @taruya Infura doesn't support personal_* api to manage accounts, you need to use a wallet provider instead. – Ismael Mar 24 at 14:56
0

You need to install a web3 layer for your lambda. See https://github.com/scenarex/web3-lambda-layer for how to do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.