A Cairo implementation of the DLC.Link protocol for managing Discreet Log Contracts (DLCs) on StarkNet.
- Install dependencies:
scarb build
- Run tests:
snforge test
Open the project in a dev container with the configuration at .devcontainer.json
. This container already has scarb, starkli, and starknet-devnet installed.
{
"name": "dev",
"image": "starknetfoundation/starknet-dev:2.9.4",
"customizations": {
"vscode": {
"extensions": [
"StarkWare.cairo1",
"tamasfe.even-better-toml"
]
}
},
"forwardPorts": [
5050
]
}
Open the first terminal tab and run the starknet-devnet
starknet-devnet --seed 0
Open the second terminal tab and run the deploy script (update the account info the .env
file)
cd scripts/
yarn
node deploy.js [devnet|testnet|mainnet]?
To run some basic tests (testing upgrades)
node basic-test.js [devnet|testnet|mainnet]?
Import the first account in the devnet's account list to the sncast profile.
cd bash_scripts/
sncast \
account import \
--url http://127.0.0.1:5050/rpc \
--name devnet-account \
--add-profile dev \
--address 0x064b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691 \
--private-key 0x0000000000000000000000000000000071d7bb07b9a64f6f78ac4c816aff4da9 \
--type oz
Run the deploy script with the sncast profile
cd bash_scripts/
sncast --profile dev script run ibtc_deploy_script
The main contract that manages DLCs. It handles:
- Vault creation and management
- DLC status tracking
- Whitelisting
- Admin controls
- Multi-signature verification
An ERC20 token contract representing wrapped BTC in the DLC system. Features:
- Minting/burning capabilities
- Role-based access control
- Configurable minter/burner roles
UI to test and sign message: https://dapp-argentlabs.vercel.app/starknetkitLatest (with EIP-712 support)
- https://github.com/argentlabs/starknet-off-chain-signature/tree/main
- https://github.com/DLC-link/dlc-solidity/tree/53a00a3f3f01fa1dbf3240e2dc73b06de63241d0/contracts
The scripts/deploy.sh
script handles the deployment of iBTC contracts to StarkNet networks.
Before running the deployment script, ensure you have:
- Scarb installed for Cairo contract compilation
- Starkli installed for StarkNet interaction
- A StarkNet account and keystore set up
Create a deploy_config.sh
file in the scripts
directory with your network configuration:
# Network RPC endpoints
export MAINNET_RPC="https://your-mainnet-rpc"
export TESTNET_RPC="https://your-testnet-rpc"
# Account and keystore paths
export STARKNET_ACCOUNT="~/.starkli/account.json"
export STARKNET_KEYSTORE="~/.starkli/keystore.json"
Basic usage:
./scripts/deploy.sh --network <network> --account-address <address>
--network
: Target network for deployment (mainnet/testnet)--account-address
: Your StarkNet account address--skip-build
: Skip contract compilation (use existing artifacts)
- Deploy to testnet with fresh build:
cd ./scripts
./deploy.sh --network testnet --account-address 0x123...
- Deploy to mainnet skipping build:
cd ./scripts
./deploy.sh --network mainnet --account-address 0x123... --skip-build
The script performs the following steps:
- Setup account and keystore
- Build contracts (unless --skip-build is used)
- Declare contracts on StarkNet
- Deploy contracts with constructor arguments
- Verify deployments by calling contract methods
- Save deployment addresses to
deployment_<network>.json
After successful deployment, contract addresses and class hashes are saved to deployment_<network>.json
:
{
"network": "testnet",
"ibtc_token": {
"address": "0x...",
"class_hash": "0x..."
},
"ibtc_manager": {
"address": "0x...",
"class_hash": "0x..."
},
"timestamp": "2024-..."
}
The script includes error handling for common scenarios:
- Missing prerequisites (scarb, starkli)
- Missing configuration
- Contract build failures
- Deployment failures
- Already deployed contracts (continues with existing addresses)