Rust-based canisters for Internet Computer Protocol with ICRC-1 token integration
Rust-based canisters for Internet Computer integration
The main canister implementing hash time lock functionality for secure cross-chain swaps on the Internet Computer. Provides ICRC-1 token integration and comprehensive swap management capabilities.
Rust-based canister implementing atomic swap functionality with ICRC-1 token support.
Creates a new hash time lock contract
Claims funds using preimage
Refunds after timelock expiration
Retrieves contract details
#[derive(CandidType, Deserialize, Clone, Debug, Serialize)]
pub struct TimeLockContract {
pub sender: String,
pub receiver: String,
pub amount: u64,
pub hashlock: String,
pub timelock: u64,
pub preimage: Option,
pub withdrawn: bool,
pub refunded: bool,
pub ledger_id: String,
}
pub async fn transfer_icrc1(
icrc1_canister: Principal,
amount: u64,
to_owner: Principal,
subaccount: Option
) -> CallResult<(TransferResult, )> {
// ICRC-1 token transfer implementation
}
Deploy canisters to Internet Computer
cd icp-canisters
npm install
dfx start --background
# Start local IC network
dfx build
# Build canisters
dfx build hashed-time-lock
# Build specific canister
dfx deploy
# Deploy all canisters
dfx deploy hashed-time-lock
# Deploy specific canister
dfx deploy --network ic
# Deploy to mainnet
cd tests
npm test
# Run all tests
npm run test:watch
# Run in watch mode
Comprehensive test suite covering canister functionality and integration.
Complete canister interface documentation
Method | Description | Parameters |
---|---|---|
new_contract |
Create hash time lock contract | NewContractRequest |
claim |
Claim funds with preimage | ClaimRequest |
refund |
Refund after expiration | RefundRequest |
Method | Description | Return Type |
---|---|---|
get_contract |
Get specific contract | Option<TimeLockContract> |
get_all_contracts |
Get all contracts | Vec<(String, TimeLockContract)> |
hash_preimage |
Hash a preimage | String |
get_version |
Get canister version | String |