ton_smart_contract_address

Crates.ioton_smart_contract_address
lib.rston_smart_contract_address
version0.0.4
sourcesrc
created_at2022-12-20 09:23:11.829871
updated_at2023-01-31 15:41:44.062347
descriptionTON smart contract addresses
homepagehttps://gitlab.com/nosensedev/tonsmartcontractaddress
repositoryhttps://gitlab.com/nosensedev/tonsmartcontractaddress
max_upload_size
id742143
size33,322
publish (github:8bitnftstudio:publish)

documentation

https://docs.rs/tonsmartcontractaddress

README

TonSmartContractAddress

Provides functions to work with TON smart contract addresses.

See Smart Contract Address for more info.

Parse any address into any other address.

    let raw = "0:ba60bfbd527c0cd2d70c6396630c50a498af015b987adaad1d4a9e287f604536";
    let bounceable = "EQC6YL-9UnwM0tcMY5ZjDFCkmK8BW5h62q0dSp4of2BFNvnA";
    let non_bounceable = "UQC6YL-9UnwM0tcMY5ZjDFCkmK8BW5h62q0dSp4of2BFNqQF";

    let raw1 = RawAddress::from_raw_str(raw).unwrap();
    let raw2 = RawAddress::from_user_friendly_str(bounceable).unwrap();
    let raw3 = RawAddress::from_user_friendly_str(non_bounceable).unwrap();

    let user_friendly1 = UserFriendlyAddress::from_raw_str(raw).unwrap();
    let user_friendly2 = UserFriendlyAddress::from_user_friendly_str(bounceable).unwrap();
    let user_friendly3 = UserFriendlyAddress::from_user_friendly_str(non_bounceable).unwrap();

Convert any address to any other address.

    let raw1 = user_friendly1.to_raw();
    let raw2 = RawAddress::from_user_friendly(&user_friendly2);

    let user_friendly1 = raw1.to_user_friendly(UserFriendlyFlag::Bounceable);
    let user_friendly2 = UserFriendlyAddress::from_raw(&raw2, UserFriendlyFlag::Bounceable).unwrap();

Build strings in any format.

    let raw_string1 = raw1.to_string();
    let user_friendly_string1 = raw1.to_user_friendly_str(UserFriendlyFlag::Bounceable);

    let raw_string2 = user_friendly1.to_raw_str();
    let user_friendly_string2 = user_friendly1.to_string();

Customize addresses

    let mut raw1 = RawAddress::from_raw_str(raw).unwrap();
    raw1.set_workchain(Workchaain::MasterChain);

    let custom_flag = unsafe{ UserFriendlyFlag::custom(0x01) };
    let user_friendly1 = raw1.to_user_friendly(custom_flag);
Commit count: 7

cargo fmt