A smart contract system for storing and retrieving SVG signatures on-chain. Each signature is stored as optimized path data and can be retrieved in various formats including SVG and base64-encoded data URIs.
- Store SVG signatures on-chain
- Optimize signature paths for gas efficiency
- Retrieve signatures as SVG or data URI
- Batch signature processing
- Custom stroke color and width support
- Node.js >= 16
- Hardhat
- An Ethereum RPC URL (for mainnet interaction)
- Clone the repository:
git clone [repository-url]
cd signature-repository
- Install dependencies:
npm install
- Configure environment:
cp .env.example .env
Edit .env
with your configuration:
ETHEREUM_RPC_URL= # Your Ethereum RPC URL
PRIVATE_KEY= # Your wallet private key
ETHERSCAN_API_KEY= # For contract verification
- SVG canvas size: 512x512 pixels
- Single path element per SVG
- Valid SVG path data (d attribute)
- Place your SVG files in a new folder under
./data/
:
mkdir ./data/your_folder_name
# Add your SVG files here
- Process and optimize signatures:
npx hardhat process-signatures --folder your_folder_name
This command:
- Extracts path data from SVGs
- Optimizes coordinates for gas efficiency
- Creates two JSON files:
./data/signatures-your_folder_name.json
(original paths)./data/signatures-your_folder_name-sm.json
(optimized paths)
- Creates optimized SVGs in
./data/your_folder_name/sm/
Store your signatures on mainnet:
npx hardhat store-signatures \
--contract 0xDE04A2537f84C8176f1B3F624405419a1E28C3F0 \
--json ./data/signatures-your_folder_name-sm.json \
--network mainnet
Options:
--contract
: Deployed contract address--json
: Path to processed signatures JSON--network
: Target network
The SignatureRepository contract is deployed on mainnet:
Mainnet: 0xDE04A2537f84C8176f1B3F624405419a1E28C3F0
# Show available accounts
npx hardhat accounts
# Compile contracts
npx hardhat compile
# Run tests
npx hardhat test
# Clean artifacts
npx hardhat clean
# Show all available commands
npx hardhat help
This project uses Ignition for deterministic deployments.
- Start a local node:
npx hardhat node
- Deploy contracts:
npx hardhat ignition deploy ./ignition/modules/SignatureRepository.ts --network localhost
The deployed contract provides several methods to interact with stored signatures:
// Store signatures
function addSignature(bytes[] calldata data) external
function addSignatures(bytes[][] calldata data) external
// Retrieve signatures
function signaturePath(address signer, uint256 index) public view returns (string memory)
function svg(address signer, uint256 index) public view returns (string memory)
function svg(address signer, uint256 index, string memory color, string memory width) public view returns (string memory)
function uri(address signer, uint256 index) public view returns (string memory)
function uri(address signer, uint256 index, string memory color, string memory width) public view returns (string memory)