Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions sign-score/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import ethers from "ethers";

const WALLET_PK = process.env.WALLET_PK;

export const handler = async (event) => {
try {
const { score, passport_id } = event;

const wallet = new ethers.Wallet(WALLET_PK);

const numberHash = ethers.utils.solidityKeccak256(
["uint256", "uint256"],
[score, passport_id]
);

const signature = await wallet.signMessage(
ethers.utils.arrayify(numberHash)
);

const responseBody = {
statusCode: 200,
body: {
signature,
passport_id,
score,
},
};

return responseBody;
} catch (error) {
console.log("Error");
console.error(error);
return {
statusCode: 500,
body: { error: error },
};
}
};

export default handler;
17 changes: 17 additions & 0 deletions sign-score/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "create-passport",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"watch:build": "tsc --watch",
"compile": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ethers": "^5.7.0"
}
}
Loading