0G Transmission service - TxMS

Rastislav ₡ORE - Sep 17 - - Dev Community

What is 0G Transmission?

0G refers to signaling and transmission used prior to the introduction of mobile data technologies such as GPRS, 3G, 4G, etc. With this technology, you can enable communication in areas without internet connectivity, as it only requires a basic cellular network.

Why is it important?

Even in well-developed areas, data transmission is not always feasible due to coverage limitations or cost constraints. For example, imagine enjoying wine 🍷 in a cellar and wanting to pay with cryptocurrency. This is possible using TxMS, which operates without data connections.

What can be transferred?

TxMS can handle any data in hexadecimal format, as described in the binary-to-text encoding process. You can utilize the Core Blockchain endpoints or set up your own TxMS server.

Let's try it!

Step 1: Create and Sign a Core Blockchain Transaction

First, you need to compose and sign a Core Blockchain transaction.

If you don't have the go-core client installed, you can download it here for your platform.

Once downloaded, make the file executable by navigating to the directory containing gocore and running the following command:

chmod +x gocore
Enter fullscreen mode Exit fullscreen mode

You can now run the client with:

./gocore --verbosity 2 --nat any console
Enter fullscreen mode Exit fullscreen mode

This opens an interactive console where you can execute commands.

Step 2: Create a New Account

To sign transactions, you need an account. You can either create a new account or import an existing one (UTC file). For now, let’s create a new account:

personal.newAccount("your_passphrase")
Enter fullscreen mode Exit fullscreen mode

Replace your_passphrase with something you will remember! If you'd rather not use a passphrase, simply omit it. The UTC file will be stored in ~/Library/Core/keystore/ (on Mac).

Step 3: Check Sync Status (Optional)

You may not be fully synchronized with the Core Blockchain, which is not strictly required but can be helpful. Use the following command to check your sync status:

xcb.syncing
Enter fullscreen mode Exit fullscreen mode

If you're synchronized, this command returns false. Synchronization consumes bandwidth and computing power, so you might want to leave it running when you're not actively using it.

Step 4: Create and Prepare a Transaction

To get the nonce for your account (which should be 0 for the first transaction), run:

web3.xcb.getTransactionCount("cb…")
Enter fullscreen mode Exit fullscreen mode

Make sure your client is synchronized to get the correct nonce.

Now, compose your first transaction:

var tx = {nonce: '0x0', energy: 21000, energyPrice: 1000000000, from: "cb…", to: "cb…", value: web3.toOre(1)}
Enter fullscreen mode Exit fullscreen mode

Here's a breakdown of the fields:

  • nonce: The transaction count (in hexadecimal format).
  • energy: The computational effort required, 21000 is standard for simple transfers.
  • energyPrice: The amount of Core you're willing to pay per unit of energy (measured in 'nucle' from Core denomination table).
  • from: The sender's ICAN address.
  • to: The recipient's ICAN address.
  • value: The amount of Core to send, using the helper function web3.toOre.

Step 5: Sign the Transaction

Before signing, you'll need to unlock your account:

personal.unlockAccount("cb…")
Enter fullscreen mode Exit fullscreen mode

You'll be prompted for your passphrase (or just press Enter if you didn't set one). The account will remain unlocked for 300 seconds (5 minutes).

Next, sign the transaction and store it in the txSigned variable:

var txSigned = xcb.signTransaction(tx)
Enter fullscreen mode Exit fullscreen mode

Step 6: Prepare the Raw Transaction for TxMS

To prepare the raw transaction, print it with:

txSigned.raw
Enter fullscreen mode Exit fullscreen mode

Copy the raw transaction, as you'll need it for the next step.

That is all what we need from Core console now. Keep it running for synchronization or shut down using the command Ctrl + D.

Step 7: Install TxMS

If you haven't already installed TxMS, you'll need Node.js installed. I recommend using nvm for Mac users. Once you've finished installing Node.js, proceed to the next step.

Install the TxMS library globally:

npm i -g txms.js
Enter fullscreen mode Exit fullscreen mode

After installation, restart your terminal and verify that txms is recognized by typing command for opening help context:

txms -h
Enter fullscreen mode Exit fullscreen mode

Step 8: Encode the Transaction with TxMS

To encode your transaction with TxMS, run:

txms -e=rawtransaction
Enter fullscreen mode Exit fullscreen mode

Replace rawtransaction with the transaction data you copied earlier. TxMS will return the encoded message. You can also use the -dl parameter to download the encrypted message to your working directory as .txms.txt.

Step 9: Send the TxMS Message via SMS

Now, copy the encoded message and send it via SMS. The message will typically split into 2-3 SMS messages, but MMS is also supported.

Make sure the TxMS service is running before sending the message to the appropriate number:

  • Mainnet: +12019715152
  • Testnet (Devín): +12014835939

Step 10: Confirm the Transaction on the Blockchain

After about 10 seconds, the transaction should appear on the Blockchain. You can verify it using Blockindex by entering the sender or recipient address.

Congratulations! You've just completed your first TxMS transaction. If you encounter issues, feel free to ask for help on our Discord, or open a thread in the forum.

We would be happy to hear about new use cases and your ideas for applying the technology. Don't hesitate to reach out to us.

. . . . .
Terabox Video Player