TrustNote Rust SDK v0.3.0 is released for testing!
By: Sunny Liu
Tags: Blockchain Development, Rust, Sdk, Python, Blockchain Technology

TrustNote Rust SDK v0.3.0

After a few weeks of hard working, on behalf of the Rust team, I am excited to announce that TrustNote Rust SDK v0.3 is now released for testing!

Rust is a language for people who value speed and stability. To provide better experiences and more application scenarios, the Rust SDK currently runs on PC and any X86 based devices, which is just the beginning of the many steps that we are trying to do achieve, to make TrustNote more inclusive that supports a larger range of devices possible.

Now please allow me to quickly walk you through how to create a wallet and transfer money using the TrustNote Rust SDK as is!

💻How to Get the SDK?

We compiled 2 versions for Ubuntu Linux and Windows, you can download them by clicking the links below:

Note: You can also compile the SDK for other target platforms. If you want to do so, the source code is available here:

https://github.com/trustnote/rust-trustnote/archive/0.3.0.zip.

🔧How to Start a Wallet using TrustNote Rust SDK ?

Let’s do it together on Ubuntu.

Get the Release

Download the package and unzip it

2. Set the permission and make it executable

chmod +x ttt

Initialize a New Wallet

./ttt init

Because you are initializing a new wallet from scratch, the system will generate a default mnemonic for you.

Import an Existing Wallet from Mnemonic

./ttt init "select initial pet jazz alone stamp copper vault private slight rocket stock"

Configuration (Optional)

Whether you are initiating a new wallet, or importing an existing wallet, in both cases, mnemonics will be stored in a file called settings.json in the same directory after the wallet is initialized.

Here is an example when you opens the file:

{

"hub_url": [

"dev.trustnote.org:6616"

],

"mnemonic": "select initial pet jazz alone stamp copper vault private slight rocket stock"

}

Note hub_url is the address of the hub in use, and dev.trustnote.org:6616 is the hub that used by the TrustNote TestNet, if you want to switch your wallet to connect to the mainnet, you can change hub_url as bob.trustnote.org:6616.

The 12 words after “mnemonic” are your personal mnemonics. You can also change the mnemonic over here, but please note the mnemonic must be generated by a TrustNote wallet otherwise it simply won’t work.

Every time is you make any changes to settings.json , you will need to manually delete trustnote_light.sqlite , the database file in the same folder and run the following command (Check the information of your wallet) to apply your changes and check if your changes take effect.

Check the Information of Your Wallet

After wallet being initialized or imported, or after the configuration being manually updated, you will be able to review the information of your wallet by running this command:

./ttt info

Then it will show your wallet’s information like this:

current wallet info:



device_address: 0IKB7F3DAVIB3YHKJYWWVSBC6CSK76IE7

wallet_public_key: xpub6D9Xmp2Y9XTpZYZ5xk4cNxSQoBufvQ5SWLATBwyaSh38G6aiCrUzUGuEtMoRMPy3a3wKJ8B6obtpUvu89sBbadqah9iXLWohTZi9FWj7JML

└──wallet_id(0): UYwIQm+PIzvY5lceD6uX+yAc86LfaC3RFobSdxGfHmk=

└──address(0/0): HU475BN5CEEPYL3WPLK5KA3FKXXN5NAD

├── path: /m/44'/0'/0'/0/0

├── pubkey: A3OTtemVlcteNZafJyXoCbE0UJ5SL74UI0cIjyJC4bCe

└── balance: 299.999MN

In this example, HU475BN5CEEPYL3WPLK5KA3FKXXN5NAD is the wallet’s address, and the wallet’s balance is 299.999 MN of TTT.

Get some TTT Test Notes for free

By default, this tutorial runs on TrustNote testnet instead of mainnet, and for testing purpose, we do provide some TTT Test Notes for free:

Open http://dev.trustnote.org/getTTT from your web browser, simple input your wallet address and press the “get TTT” button.

Usually the TTT Test Notes will be transferred to your wallet in about 3~5 seconds, sometimes it may take up to 1~2 minutes. You can check the new balance of your wallet by running the ./TTT info command again.

Note: TTT Test Notes can be used to issue tokens and pay for the transaction fees on the testnet, however it doesn’t work on TrustNote’s mainnet, and it can’t be traded on those crypto-currency markets where TTT is currently being listed.

Transfer the Money (TTT Test Notes)

Before we move to this vital step, please make sure you have a seperate wallet addresses for testing. In this tutorial, we will use address OKLGMIWBCFITVWKZF3JASA23OMZLICSH as a sample.

If you don’t have a separate address can be used for testing, don’t worry, we provided you an easy way to generate address and its mnemonic for your testing purpose.

Simply visit http://developers.trustnote.org/fancy-address/index.html and get your testing wallet address including its mnemonic.

Now let’s transferring the TTT Test Notes from your new wallet to the testing address by running the following command:

./ttt send -p OKLGMIWBCFITVWKZF3JASA23OMZLICSH 9.99 -t hello

From the return message below, you will see the from address and to address, and the amount being transferred.

Note -t specifies any texts for your own record, it is an optional field but please don’t forget that texts will be saved on a blockchain!

refresh history done



FROM : HU475BN5CEEPYL3WPLK5KA3FKXXN5NAD

TO :

address : OKLGMIWBCFITVWKZF3JASA23OMZLICSH, amount : 9.99

UNIT : ly1DYqhjP/QngSCHP6t1NqumabOZQdR5bSiqzDDt7bc=

TEXT : hello

DATE : 2018-08-15 15:59:27.973

Check the Balance

Again, we have several options here:

Check the balance including both confirmed and unconfirmed:

./ttt balance

2. Check the balance (confirmed only):

./ttt balance -s

3. Check the balance (unconfirmed only):

./ttt balance -p

Tip: As TrustNote uses UTXO model, sometime you will see strange transactions such as: When Bob transfers 100 TTT to Alice, you may see Bob transferred 150 TTT to Alice, and then 50 TTT are transferred from Alice back to Bob, that’s why sometime you may notice there is 50 TTT pending transaction (unconfirmed) during the process. But after being confirmed, everything should come to normal again.

What else I can do with the Rust SDK?

Running SDK in a different location (file directory) will generate settings.json file in different places. This means that you can use Python, PHP, or any other scripting language to build a multi-user wallet system.

For example, you can put the Rust SDK on the server and provide your web-based multi-account wallet service running on TrustNote network.