Skip to content

1Shot-API/1shotpay-subwallet

Repository files navigation

1ShotPay SubWallet

This is a simple EIP-7702 smart wallet designed for use with EOA that will temporarily hold ERC-20 tokens in escrow until spent by an agent EOA that has been added to the subaccount's approved signer list.

The approved signer can, for example, sign an EIP-3009 authorization to spend USDC being held in the upgraded subwallet address to spend on x402 resources. This approach removes the need to dump a complete budget up-front into an EOA controlled by an autonomous agent while still being compatible with paying for x402 resources.

Sample Hardhat 3 Beta Project (node:test and viem)

This project showcases a Hardhat 3 Beta project using the native Node.js test runner (node:test) and the viem library for Ethereum interactions.

To learn more about the Hardhat 3 Beta, please visit the Getting Started guide. To share your feedback, join our Hardhat 3 Beta Telegram group or open an issue in our GitHub issue tracker.

Project Overview

This example project includes:

  • A simple Hardhat configuration file.
  • Foundry-compatible Solidity unit tests.
  • TypeScript integration tests using node:test, the new Node.js native test runner, and viem.
  • Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.

Usage

Running Tests

To run all the tests in the project, execute the following command:

npx hardhat test

You can also selectively run the Solidity or node:test tests:

npx hardhat test solidity
npx hardhat test nodejs

Deployment

This project includes Ignition modules to deploy contracts. You can deploy to a locally simulated chain, Sepolia, or Base.

To run the deployment to a local chain:

npx hardhat ignition deploy ignition/modules/SubWallet.ts

Configuration Variables

Variable Used for Where to get it
BASE_RPC_URL Base deployment & scripts Alchemy, Infura, QuickNode, or https://mainnet.base.org
BASE_PRIVATE_KEY Deployer/signer for Base Your EOA private key (without 0x)
ETHERSCAN_API_KEY Contract verification on Basescan/Etherscan Etherscan API
SEPOLIA_RPC_URL Sepolia deployment Same providers, Sepolia endpoint
SEPOLIA_PRIVATE_KEY Deployer for Sepolia Your EOA private key

Base Network

To deploy to Base mainnet, configure your private key and RPC provider:

  1. Create a .env file in the project root (add .env to .gitignore):

    BASE_RPC_URL=https://mainnet.base.org
    BASE_PRIVATE_KEY=your_private_key_here
    ETHERSCAN_API_KEY=your_etherscan_api_key
    

    Or use an RPC provider like Alchemy, Infura, or QuickNode for BASE_RPC_URL.

  2. Set the config variables using hardhat-keystore:

    npx hardhat keystore set BASE_RPC_URL
    npx hardhat keystore set BASE_PRIVATE_KEY
    npx hardhat keystore set ETHERSCAN_API_KEY

    Or set them as environment variables before running Hardhat.

  3. Deploy to Base:

    npx hardhat ignition deploy ignition/modules/SubWallet.ts --network base

Sepolia

To deploy to Sepolia, set SEPOLIA_RPC_URL and SEPOLIA_PRIVATE_KEY:

npx hardhat keystore set SEPOLIA_PRIVATE_KEY
npx hardhat ignition deploy ignition/modules/SubWallet.ts --network sepolia

Verifying Contracts

  1. Get an API key from Etherscan (works for Etherscan, Basescan, Sepolia, and other Etherscan-family explorers).

  2. Set the config variable:

    npx hardhat keystore set ETHERSCAN_API_KEY
  3. Verify a deployed contract (SubWallet has no constructor args):

    npx hardhat verify --network base DEPLOYED_ADDRESS

    For Sepolia:

    npx hardhat verify --network sepolia DEPLOYED_ADDRESS
  4. If you deployed with the production build profile (optimizer enabled), add --build-profile production:

    npx hardhat verify --network base --build-profile production DEPLOYED_ADDRESS

Check Balance

To print the ETH balance of the configured deployer account:

npx hardhat run scripts/balance.ts --network base

About

minimalist eip7702 smart wallet with eip1271 signature verification for x402 payments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors