This is an example repository showing how to do gasless uploads to Arweave using Irys with a technique called server-side signing. There is code for using EVM and Solana wallets.
This project is a fork of the Irys Provenance Toolkit.
- Clone this repository
cd gasless-uploader
- Rename
.env.local.example
to.env.local
and add EVM and SOL private keys npm install
npm run dev
A NextJS server route is setup with a public / private key pair.
The end-user uploads a file and then:
- The client requests the server's public key
- The client asks the server to sign the upload
- The server signs the upload and returns it to the client
- The client creates a Provider using the public key and the signed data
- The client uses the Provider object to create a WebIrys object
- The client uses the WebIrys object to upload the file
getIrys.ts
: Configures an Irys object using parameters in.env.local
gaslessFundAndUpload.ts
: When passed a File object, ensures the node has a sufficient to pay for the upload, creates a Provider object using the server's private key and finally uploads the file.
There are two sets of server routes, one for EVM chains and one for Solana.
publicKeyEVM
: Returns the public key for the server's wallet. This is the first route called by the client.lazyFundEVM
: Optional route used for lazy-funding uploads.signDataEVM
: Signs the data provided using the server's private key.
publicKeySOL
: Returns the public key for the server's wallet. This is the first route called by the client.lazyFundSOL
: Optional route used for lazy-funding uploads.signDataSOL
: Signs the data provided using the server's private key.