Managing token metadata
Token Metadata can be added / updated and removed as key / value pairs
Retrieving Metadata
println!("\n1. Get Token Metadata");
println!("=====================");
let token_info = match client.get_token_metadata(token_address).await {
Ok(mint_info) => {
println!("{}", mint_info);
Some(mint_info)
}
Err(e) => {
print_detailed_error("Could not get token metadata", &e);
None
}
};
Updating Metadata
// 9. Update token metadata
println!("\n9. Update Token Metadata");
println!("========================");
let metadata_payload = TokenMetadataUpdatePayload {
recent_epoch: state.epoch,
recent_checkpoint: state.checkpoint,
chain_id,
nonce: current_nonce,
name: "Updated Test Token".to_string(),
uri: "https://example.com/updated-metadata.json".to_string(),
additional_metadata: vec![MetadataKVPair {
key: "version".to_string(),
value: "2.0".to_string(),
}],
token: token_address,
};
match client
.update_token_metadata(metadata_payload, private_key)
.await
{
Ok(response) => {
println!("Metadata updated - Tx: {}", response.hash);
}
Err(e) => {
print_detailed_error("Could not update token metadata", &e);
}
}
Last updated