Andromeda
Search
⌃K

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. Each locked NFT has a specific lock id which is compromised of the CW721 contract address concatenated with the token_id.
For example, if an NFT with token id "token-1" is sent from the CW721 ADO " andr1uqju2r...daskv9a6m", then the lock_id would be:
"andr1uqju2r...daskv9a6mtoken-1"
Ado_type: cw721-timelock

InstantiateMsg

Rust
pub struct InstantiateMsg {}

ExecuteMsg

ReceiveNft

Receives a token from a SendNftand 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":"andr1...",
"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": "andr1...tokenid"
}
}
Name
Type
Description
lock_id
String
A concatinated id made of the nft contract address+token id.

AndrReceive

The rest of the executes can be found in the AndrReceive section.

QueryMsg

LockedToken

Queries details on the locked token with the specified lock_id.
Rust
JSON
pub enum QueryMsg {
#[returns(LockDetails)]
LockedToken {
lock_id: String
},
}
{
"locked_token":{
"lock_id":"andr1...tokenid"
}
}
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":"andr1...",
"expiration":{
"at_time": "128193232"
},
"nft_id": "3",
"nft_contract":"andr1..."
}
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

A set of base queries common to all Andromeda ADOs. Check AndrQuery.