Deploying Contracts
Specter supports any EVM-compatible deployment method. This guide covers Foundry (recommended) and direct RPC deployment.
With Foundry
Basic deployment
forge create src/MyContract.sol:MyContract \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445 \
--private-key $PRIVATE_KEY
With constructor arguments
forge create src/MyToken.sol:MyToken \
--constructor-args "My Token" "MTK" 18 \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445 \
--private-key $PRIVATE_KEY
With a keystore file
KPWD=$(cat /path/to/password-file)
PK=$(cast wallet decrypt-keystore /path/to/keystore \
--unsafe-password "$KPWD" | grep "private key")
forge create src/MyContract.sol:MyContract \
--private-key $PK \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445
Deployment scripts
// script/Deploy.s.sol
pragma solidity ^0.8.24;
import "forge-std/Script.sol";
import "../src/MyContract.sol";
contract DeployScript is Script {
function run() external {
vm.startBroadcast();
new MyContract();
vm.stopBroadcast();
}
}
forge script script/Deploy.s.sol \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445 \
--broadcast \
--private-key $PRIVATE_KEY
Interacting with deployed contracts
Read a value
cast call $CONTRACT_ADDRESS "balanceOf(address)(uint256)" $WALLET_ADDRESS \
--rpc-url https://testnet.specterchain.com
Send a transaction
cast send $CONTRACT_ADDRESS "transfer(address,uint256)" $RECIPIENT $AMOUNT \
--rpc-url https://testnet.specterchain.com \
--chain-id 5445 \
--private-key $PRIVATE_KEY
Get a transaction receipt
cast receipt $TX_HASH --rpc-url https://testnet.specterchain.com
Deploying Ghost Protocol contracts
If your contract needs to interact with Ghost Protocol contracts (CommitRevealVault, GhostERC20, etc.), you'll need to link the PoseidonT3 library. See Foundry Setup for the library linking configuration.
warning
Contracts that call the Ghostmint precompile at 0x0808 must be authorized via governance. Only the NativeAssetHandler contract is currently authorized. See Ghostmint Authorization.
Gas considerations
- Minimum gas price: 1 gwei (1,000,000,000 wei)
- ZK proof verification: ~200K gas (Groth16 pairing check via
ecPairingprecompile) - Commit operation: ~150K gas (Merkle tree insertion + event emission)
- Reveal operation: ~350K gas (proof verification + token mint + nullifier registration)