## z-address geneneration
z-address i.e. shielded address, is the address format that TRONZ uses. It is determined by an `
sk` and `
d` key. One can publish its z-address and receive shielded transactions.
sk` is the hidden private key. `
d` is an identifier of different addresses generated from `
sk`, can be used to implement HD-wallets. All other keys are used in different occasions.
Take an address as an example: `
ztron1m445gx74mjuuyhkyru5hrx886jszfga4a7dk3mg4uarrl0cru649jz4928tm6rqul2pg645hqv5`. The address is in [bech32](🔗) format. `
ztron1` is the fixed prefix. The remains are encoded value of `
pkD` and `
Comparing to the original TRON address format `
T-....`, one can call it a transparent address or T-address.
Key and z-address related APIs are:
There are 3 main tasks related to shielded transaction:
transfer from T-address to z-address, `
mint` for shielded trc20
transfer between z-addresses, `
transfer` for shielded trc20
transfer from z-address to T-address, `
burn` for shielded trc20
## Shielded TRC20 Contract
### Prerequisite - a shielded TRC20 contract
The shielded contract is at <https://raw.githubusercontent.com/tronprotocol/java-tron/feature/shieldedUSDT/deploy/ShieldedTRC20.sol>.
It can only be compiled with solidity variation from TRON: <https://github.com/tronprotocol/solidity>, and the code branch is `
Deploy the code with constructor parameter `
(TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3, 18)`. We got a shielded TRC20 address TEkQTDyZmbY6hngxdAsxzxy9r3bUNhRjdS.
Where TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3 is the TRC20 address of JST token in Nile Testnet, `
1` is the exponent of the scaling factor.
### Transfer to z-address - mint
Before any transferring, use the `
approve` method of the original TRC20 to approve the required amount of tokens to the shielded TRC20 contract.
Suppose we want to transfer tokens to the address `
First, create `
Then, construct the shielded contract parameters:
from_amount` is of string type
value` is `
from_amount` divided by `
Then we got the response, the only one we care is `
[855d175e]`(signature of mint()) with `
trigger_contract_input`, we got the calling parameter.
Sign the `
TriggerSmartContract` transaction with the T-address and broadcast.
### Query incoming notes
wallet/scanshieldedtrc20notesbyivk` with `
nk`. You can only scan 1000 blocks at once.
The returned note has a field called `
### Transfer between z-addresses - transfer
All transfers are based on `
note`. You can transfer 1-2 notes to 1-2 notes. The total balanced must be matched.
alpha` and `
rcm` are generated by `
### Query outgoing notes
wallet/scanshieldedtrc20notesbyovk` with `
### Is a note spent
wallet/isshieldedtrc20contractNoteSpent` with `
### Transfer from z-address to T-address - burn
Almost the same as a `
transfer`. The `
TriggerSmartContract` transaction can be broadcasted by anyone.
The detailed usage document is [Here](🔗).