Skip to content

Commit

Permalink
docs: add contract signature examples (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
horsefacts authored Dec 15, 2023
1 parent 20b6575 commit e63b001
Show file tree
Hide file tree
Showing 7 changed files with 3,368 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cache/
17 changes: 17 additions & 0 deletions packages/hub-nodejs/examples/contract-signatures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Working with EIP-712 signatures

This example app demonstrates how to create and use EIP-712 signatures to sponsor onchain transactions on behalf of users.

Every onchain action in the Farcaster protocol can be performed by a third party on behalf of the end user by collecting a typed signature and providing it to the Farcaster smart contracts. This makes it possible to pay gas and sponsor onchain transactions for your users without asking them to pay a fee or send a transaction from their wallet.

The structured format of EIP-712 signatures makes them more secure for the end user and easier for wallets to parse, but they can be difficult to construct and work with as an application developer. This demo app shows how to call every signature based function in the Farcaster contracts, including registering an account, transferring an fid, and adding/removing signer keys.

This example uses [Hardhat](https://hardhat.org/) to run a local node that simulates OP Mainnet, where the Farcaster contracts are deployed.

### Run locally

1. Clone the repo locally
2. Navigate to this folder with `cd packages/hub-nodejs/examples/make-cast`
3. Run `yarn install` to install dependencies
4. Run `yarn chain:start` to start Hardhat
5. Run `yarn start`
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
networks: {
hardhat: {
chainId: 10,
forking: {
url: "https://mainnet.optimism.io",
},
},
},
};
Loading

0 comments on commit e63b001

Please sign in to comment.