https://github.com/jimlynchcodes/eth-thenticated-nodejs-requests
Example of validating sender address of a post request on a nodejs backend
https://github.com/jimlynchcodes/eth-thenticated-nodejs-requests
Last synced: about 1 year ago
JSON representation
Example of validating sender address of a post request on a nodejs backend
- Host: GitHub
- URL: https://github.com/jimlynchcodes/eth-thenticated-nodejs-requests
- Owner: JimLynchCodes
- License: mit
- Created: 2021-10-23T16:55:02.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-26T23:19:58.000Z (over 4 years ago)
- Last Synced: 2025-02-04T12:01:38.482Z (over 1 year ago)
- Language: JavaScript
- Size: 1.33 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eth-thenticated-nodejs-requests
Example of validating sender address of a post request on a nodejs backend
# What's Here

## 1. Frontend
A react project (made with create-react-app) that has only one button- "send stuff" which sends some json data and the signed request.
Note that this project ***does not connect to any smart contract***.
Instead, it uses metamask and web3 to create a signed message and then sends it off to our nodejs backend server.
{
sender: "0x123123123123",
number: 15,
action: "attack"
}
```
npm start
```
## 2. Backend
An express.js server-side node.js project with a single post endpoint, handling the "send stuff" call from our single button.
This project also uses web3, but instead of singing a message it uses the "web3.eth.accounts.recover" to recover the signer address.
We return an error if the user tries to call with a post body where "sender" is different from the signer address.
_This then gives us a "msg.sender" guarantee in node.js the same as we have in solidity!_
```
npm start
```