Skip to content

emma31-dev/Defi-wallet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Defi-wallet

A decentralized finance wallet application with a Solidity smart contract backend and Rust API server.

Project Structure

  • contract/ - Solidity smart contracts (Foundry project)
  • backend/ - Rust API server (Axum)
  • app/ - Frontend application
  • migrations/ - Database migrations

Prerequisites

  • Rust (with cargo)
  • Foundry (forge, anvil)
  • Just task runner (optional but recommended)

Quick Start

1. Start the Local Blockchain

In a terminal, start the Anvil local blockchain:

just run_rpc

Or without just:

anvil

Anvil will start on http://127.0.0.1:8545 with 10 pre-funded test accounts.

2. Deploy the Contract

In a second terminal, deploy the Wallet contract to your local Anvil node:

just deploy

Or without just:

cd contract && forge script script/Wallet.s.sol:WalletScript \
    --rpc-url http://127.0.0.1:8545 \
    --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
    --broadcast

Note the deployed contract address from the output and update CONTRACT_ADDRESS in backend/.env if needed.

3. Run the Backend

In a third terminal, start the Rust backend server:

just run_backend

Or without just:

cd backend && cargo run

The backend will start on http://127.0.0.1:3000.

Development

Building Contracts

just build_contracts
# or: cd contract && forge build

Testing

Run contract tests:

just test_contracts
# or: cd contract && forge test

Run backend tests:

just test_backend
# or: cd backend && cargo test

Smart Contract

The main contract is Wallet.sol, which provides:

  • Deposit ETH
  • Withdraw ETH
  • Transfer between accounts within the wallet
  • Balance tracking per user

Configuration

Backend configuration is in backend/.env:

  • RPC_ENDPOINT - Ethereum RPC endpoint (default: Anvil local node)
  • CONTRACT_ADDRESS - Deployed Wallet contract address
  • SERVER_ADDRESS - Backend server address
  • DATABASE_URL - SQLite database path

License

See LICENSE file for details.

About

A decentralized finance wallet application with a Solidity smart contract backend and Rust API server.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors