Andromeda
Search…
CW721 Timelock

Introduction

Lock an NFT with a contract for a certain amount of time (currently between one day & one year). Once the timelock has expired, anyone can call the claim function which will send the NFT to the defined recipient.
Ado_type: cw721-timelock

InstantiateMsg

Rust
pub struct InstantiateMsg {}

ExecuteMsg

ReceiveNft

Receives a token from a Send and locks it based on the parameters defined in the StartLock hook message.
Rust
pub enum ExecuteMsg {
ReceiveNft(Cw721ReceiveMsg),
}

Cw721ReceiveMsg

pub struct Cw721ReceiveMsg {
pub sender: String,
pub token_id: String,
pub msg: Binary,
}
The msg field in the Cw721ReceiveMsg struct should be a Cw721HookMsg of type StartLock.

Cw721HookMsg

The minimum lock_time that can be set is 86_400 which is one day.
The maximum lock_time that can be set is 31_536_000 which is one year.
Rust
JSON
pub enum Cw721HookMsg {
StartLock {
recipient: Option<String>,
lock_time: u64,
},
}
{
"start_lock":{
"recipient":"juno1...",
"lock_time": 100000
}
}
Name
Type
Description
recipient
Option<String>
The address to receive the NFT after the lock is done. Defaults to the sender.
lock_time
u64
The amount of time to lock the NFT. Should be provided in seconds. The minimum amount of time is 1 day (86400 seconds). The max amount of time is 1 year (31536000 seconds).

Claim

Transfers the given token to the recipient once the time lock has expired.
Rust
JSON
pub enum ExecuteMsg {
Claim {
lock_id: String,
},
}
{
"claim":{
"lock_id": "juno1...53"
}
}
Name
Type
Description
lock_id
String
A concatinated id made of the nft contract address+token id.

AndrReceive

QueryMsg

LockedToken

Queries details on the locked token with the specified lock_id.
Rust
JSON
pub enum QueryMsg {
LockedToken {
lock_id: String
},
}
{
"locked_token":{
"lock_id":"juno1...3"
}
}
Name
Type
Description
lock_id
String
A concatinated id made of the nft contract address+token id.

LockedDetails

Rust
JSON
pub struct LockDetails {
pub recipient: String,
pub expiration: Expiration,
pub nft_id: String,
pub nft_contract: String,
}
{
"recipient":"juno1...",
"expiration":{
"at_time": "128193232"
},
"nft_id": "3",
"nft_contract":"juno1..."
}
Name
Type
Description
recipient
String
The recipient of the NFT once the lock time has passed.
expiration
When the lock time will be completed and the NFT can be claimed.
nft_id
String
The id of the NFT.
nft_contract
String
The address of the NFT contract.

AndrQuery

Check AndrQuery.
Copy link
Outline
Introduction
InstantiateMsg
ExecuteMsg
ReceiveNft
Claim
AndrReceive
QueryMsg
LockedToken
AndrQuery