Wallet Transactions
How to transfer tokenized fiat to other accounts using publicmint-web3.js
Last updated
Was this helpful?
How to transfer tokenized fiat to other accounts using publicmint-web3.js
Last updated
Was this helpful?
Transactions in the Public Mint blockchain are quite similar to Ethereum. All transactions take place through ERC-20-like smart contracts that handle the tokenised fiat. This means that checking balances, sending or receiving fiat require calls to that fiat currency's smart contract, with the default being USD.
Read on to learn your way around the basics.
Within the code, Public Mint uses the same monetary units as Ethereum when referring to its native tokens - Wei and Ether. Even though the name is the same, for all effects these units represent tokenized fiat in the Public Mint ecosystem.
Please DO NOT send funds into any of the addresses shown in this documentation as they are published on the internet, taken from the web3.js documentation. Doing so may result in the loss of your funds!
If you haven't created a Public Mint and don't have your own, then the first thing you need is a wallet. Start by connecting to a node - check the to get the code.
After that, it's simple - instantiate a wallet and add the private key of your funded account:
And that's it - keep your keys safe and don't show anyone.
Let's use web3 instance to check the balance of a Public Mint address.
Just like Ethereum, transactions in the Public Mint blockchain can either read or write to the blockchain. While read-type transactions are free, writing (i.e. changing the state) entails fees. Ethereum fees are paid in ETH. In contrast, all fees on Public Mint are paid in fiat.
After instantiating web3 and create a connection to a Public Mint node, instantiate a local version of the ERC20_USD contract:
Then all you need to do is call the contract's getBalances
method for your wallet's address.
Here is what you need to do to send funds to another Public Mint address.
After getting a wallet and checking your balance to make sure everything is working, you can start transacting.
Here's the full code snippet to get you through all the steps:
The ERC20 token balance is mapped directly against the native token - for all effects, they are the same. While you can use the balanceOf
, for performance reasons, we strongly recommend you use the JSON-RPC getBalances
to do it.
And that's it. To make sure it worked, you should check the balance on both accounts .
For a comprehensive list of transactions with examples, please check the 's list of methods.