Skip to content

Commit

Permalink
GitBook: [master] 292 pages modified
Browse files Browse the repository at this point in the history
  • Loading branch information
mzfshark authored and gitbook-bot committed Jul 3, 2021
1 parent 74d7568 commit 2ed742d
Show file tree
Hide file tree
Showing 14 changed files with 536 additions and 0 deletions.
13 changes: 13 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
* [Multi-Signature](networks/tron-network/tron-protocol/multi-signature/README.md)
* [Example Process Flow](networks/tron-network/tron-protocol/multi-signature/example-process-flow.md)
* [Concensus](networks/tron-network/tron-protocol/concensus.md)
* [TRX AND TRC TOKEN](networks/tron-network/trx-and-trc-token/README.md)
* [TRX](networks/tron-network/trx-and-trc-token/trx/README.md)
* [TRX Transfer](networks/tron-network/trx-and-trc-token/trx/trx-transfer.md)
* [Query TRX balance](networks/tron-network/trx-and-trc-token/trx/query-trx-balance.md)
* [TRC-10](networks/tron-network/trx-and-trc-token/trc-10/README.md)
* [Issue TRC-10 token](networks/tron-network/trx-and-trc-token/trc-10/issue-trc-10-token.md)
* [Participate TRC-10](networks/tron-network/trx-and-trc-token/trc-10/participate-trc-10.md)
* [TRC-10 Transfer](networks/tron-network/trx-and-trc-token/trc-10/trc-10-transfer.md)
* [Query TRC-10 balance](networks/tron-network/trx-and-trc-token/trc-10/query-trc-10-balance.md)
* [TRC-10 Transfer in Smart Contracts](networks/tron-network/trx-and-trc-token/trc-10/trc-10-transfer-in-smart-contracts.md)
* [Other TRC-10 Interfaces](networks/tron-network/trx-and-trc-token/trc-10/other-trc-10-interfaces.md)
* [TRC-20](networks/tron-network/trx-and-trc-token/trc-20/README.md)
* [Protocol Interface](networks/tron-network/trx-and-trc-token/trc-20/protocol-interface.md)
* [Ethereum \(ERC\)](networks/ethereum-erc/README.md)
* [Ether - Introduction](networks/ethereum-erc/ether-introduction/README.md)
* [The Ethereum Foundation](networks/ethereum-erc/ether-introduction/the-ethereum-foundation.md)
Expand Down
2 changes: 2 additions & 0 deletions networks/tron-network/trx-and-trc-token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TRX AND TRC TOKEN

5 changes: 5 additions & 0 deletions networks/tron-network/trx-and-trc-token/trc-10/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TRC-10

TRC-10 tokens are issued by system contract. TRC-10 is a technical token standard supported by the TRON blockchain natively without the TRON Virtual Machine \(TVM\). Every account is capable of issuing tokens at the expense of 1024 TRX. Users can lock their tokens in separately. To issue tokens, the issuer needs to specify a token name, total capitalization, the exchange rate to TRX, circulation duration, description, website, maximum bandwidth points consumption per account, total bandwidth points consumption, and token freeze.


Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Issue TRC-10 token

**HTTP API:**HTTP

```text
wallet/createassetissue
Description: Issue a token
demo: curl -X POST http://127.0.0.1:8090/wallet/createassetissue -d '{
"owner_address":"41e552f6487585c2b58bc2c9bb4492bc1f17132cd0",
"name":"0x6173736574497373756531353330383934333132313538",
"abbr": "0x6162627231353330383934333132313538",
"total_supply" :4321,
"trx_num":1,
"num":1,
"start_time" : 1530894315158,
"end_time":1533894312158,
"description":"007570646174654e616d6531353330363038383733343633",
"url":"007570646174654e616d6531353330363038383733343633",
"free_asset_net_limit":10000,
"public_free_asset_net_limit":10000,
"frozen_supply":{"frozen_amount":1, "frozen_days":2}
}'
Parameter owner_address: Owner address, default hexString
Parameter name: Token name, default hexString
Parameter abbr: Token name abbreviation, default hexString
Parameter total_supply: Token total supply
Parameter trx_num: Define the price by the ratio of trx_num/num,
Parameter num: Define the price by the ratio of trx_num/num
Parameter start_time: ICO start time
Parameter end_time: ICO end time
Parameter description: Token description, default hexString
Parameter url: Token official website url, default hexString
Parameter free_asset_net_limit: Token free asset net limit
Parameter public_free_asset_net_limit: Token public free asset net limit
Parameter frozen_supply: Token frozen supply
Parameter permission_id: Optional, for multi-signature use
Return: Transaction object
Note: The unit of 'trx_num' is SUN
```

**Tronweb Example:**JavaScript

```text
const privateKey = "...";
var createAssetAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
const trc_options = {
name : "test",
abbreviation : "tt",
description : "fortest",
url : "www.baidu.com",
totalSupply : 10000000,
trxRatio : 1,
tokenRatio : 1,
saleStart : 1581929489000,
saleEnd : 1581938187000,
freeBandwidth : 0,
freeBandwidthLimit : 0,
frozenAmount : 0,
frozenDuration : 0,
precision : 6
}
//Create an unsigned transaction that issue trc10 token,equivalent to createToken
const tradeobj = await tronWeb.transactionBuilder.createAsset(
trc_options,
createAssetAddress
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
//sign
const signedtxn = await tronWeb.trx.sign(
tradeobj,
privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
signedtxn
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
```

**Wallet-cli Example :**wallet-cli command

```text
#Usage : AssetIssue [OwnerAddress] AssetName AbbrName TotalSupply TrxNum AssetNum Precision StartDate EndDate Description Url FreeNetLimitPerAccount PublicFreeNetLimit FrozenAmount0 FrozenDays0 ... FrozenAmountN FrozenDaysN
AssetIssue TestToken TT 100000 1 1 6 "2020-02-19 22:25:00" "2020-03-20" "This is a TRC10 Token" "https://shasta.tronscan.org/" 0 0
```

Please follow the instructions below to complete this transaction:

1. Tip: "Please confirm and enter your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction.", Enter "y" or "Y" to confirm the transaction;
2. Tip: "lease choose your key for sign. ...... Please choose between 1 and 2", select the serial number of the sign account;
3. Tip: "Please input your password.", Enter your local password;
4. Tip: "AssetIssue TestToken successful !!", which indicates that successfully issued TRC10 tokens.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Other TRC-10 Interfaces

| Serial number | Interface name | Interface Description |
| :--- | :--- | :--- |
| 1 | [easytransferassetbyprivate](https://developers.tron.network/reference#easy-transfer-asset-by-private) | easy transfer TRC10 token with your private key |
| 2 | [easytransferasset](https://developers.tron.network/reference#easy-transfer-asset) | easy transfer TRC10 token with your password |
| 3 | [getassetissuebyaccount](https://developers.tron.network/reference#walletgetassetissuebyaccount) | Query the TRC10 token issued by the account |
| 4 | [getassetissuebyid](https://developers.tron.network/reference#walletgetassetissuebyname) | Query TRC10 tokens by token id |
| 5 | getassetissuebyname | Query TRC10 tokens by token name |
| 6 | getassetissuelistbyname | Query TRC10 Token List by token name |
| 7 | [getassetissuelist](https://developers.tron.network/reference#walletgetassetissuelist) | Query the list of all TRC10 tokens. |
| 8 | [getpaginatedassetissuelist](https://developers.tron.network/reference#walletgetassetissuelist) | Query the list of TRC10 tokens by page |
| 9 | [unfreezeasset](https://developers.tron.network/reference#walletunfreezeasset-1) | Unfreeze TRC10 tokens that have ended their freezing period. |
| 10 | [updateasset](https://developers.tron.network/reference#walletupdateasset) | Upadte TRC10 token information |

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Participate TRC-10

**HTTP API:**HTTP

```text
wallet/participateassetissue
Description: Participate a token
demo: curl -X POST http://127.0.0.1:8090/wallet/participateassetissue -d '{
"to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0",
"owner_address":"41e472f387585c2b58bc2c9bb4492bc1f17342cd1",
"amount":100,
"asset_name":"3230313271756265696a696e67"
}'
Parameter to_address: The issuer address of the token, default hexString
Parameter owner_address: The participant address, default hexString
Parameter amount: The number of trx participating in token issuance
Parameter asset_name: Token id, default hexString
Parameter permission_id: Optional, for multi-signature use
Return: Transaction object
Note: The unit of 'amount' is the smallest unit of the token
```

**Tronweb Example:**JavaScript

```text
const privateKey = "...";
var issuerAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
var tokenID= "1000088";
var amount = 1000;
var buyerAddress = "TVDGpn4hCSzJ5nkHPLetk8KQBtwaTppnkr";
//Creates an unsigned ICO token purchase transaction.
const tradeobj = await tronWeb.transactionBuilder.purchaseToken(
issuerAddress,
tokenID,
amount,
buyerAddress,
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
//sign
const signedtxn = await tronWeb.trx.sign(
tradeobj,
privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
signedtxn
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
```

**Wallet-cli Example :**wallet-cli command

```text
#Usage : ParticipateAssetIssue [OwnerAddress] ToAddress AssetID Amount
ParticipateAssetIssue TQmDzierQxEFJm1dT5YXnTXqVAfdN9HtXj 1000099 1000
```

Please follow the instructions below to complete this transaction:

1. Tip: "Please confirm and enter your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction.", Enter "y" or "Y" to confirm the transaction;
2. Tip: "lease choose your key for sign. ...... Please choose between 1 and 2", select the serial number of the sign account;
3. Tip: "Please input your password.", Enter your local password;
4. Tip: "ParticipateAssetIssue 1000099 1000 from TQmDzierQxEFJm1dT5YXnTXqVAfdN9HtXj successful !!", which indicates that Successfully participated in TRC10 tokens.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Query TRC-10 balance

**HTTP API:**HTTP

```text
wallet/getaccount
Description: Query an account information
demo: curl -X POST http://127.0.0.1:8090/wallet/getaccount -d
'{
"address": "41E552F6487585C2B58BC2C9BB4492BC1F17132CD0"
}'
Parameter address: Default hexString
Return: Account object
```

**Tronweb Example:**JavaScript

```text
const privateKey = "...";
var address = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
//Query the information of an account, and check the balance by assetV2 in the return value.
const tradeobj = await tronWeb.trx.getAccount(
address,
);
console.log('- Output:', tradeobj, '\n');
```

**Wallet-cli Example :**wallet-cli commamd

```text
#Usage : GetAccount Address
GetAccount TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# TRC-10 Transfer in Smart Contracts

## Introduction

Compared to TRC-20 tokens, TRC-10 tokens face a user experience flexibility issue. In Odyssey 3.2, developers and their smart contract callers can interact with TRC-10 token via smart contracts according to the contract logic, do TRC-10 token transfers in smart contracts, giving them more control to implement their token in business scenarios. Unlike TRC-20 tokens, sending TRC-10 tokens is like transferring TRX in a contract, TRON developers added an interface specifically for TRC-10 transfers and queries in solidity.

**Example of transferring trc10 in a contract**Solidity

```text
pragma solidity ^0.5.0;
contract transferTokenContract {
constructor() payable public{}
function() payable external {}
function transferTokenTest(address payable toAddress, uint256 tokenValue, trcToken id) payable public {
toAddress.transferToken(tokenValue, id);
}
function msgTokenValueAndTokenIdTest() public payable returns(trcToken, uint256){
trcToken id = msg.tokenid;
uint256 value = msg.tokenvalue;
return (id, value);
}
function getTokenBalanceTest(address accountAddress) payable public returns (uint256){
trcToken id = 1000001;
return accountAddress.tokenBalance(id);
}
}
```

**TRC10 token type**
Odyssey\_v3.2 defined a new type \(trcToken\) for TRC10 token, which represents the tokenId in a token transfer operation. TRC10 token can be converted to uint256 type and vice versa.

```text
trcToken id = 1000001;
```

**TRC10 transfer in contract**

```text
address.transferToken(uint256 tokenValue, trcToken tokenId)
```

**Query the TRC10 balance in the contract**

```text
address.tokenBalance(trcToken) returns(uint256 tokenAmount)
```

Odyssey\_v3.2 defines a new tokenBalance function for TRC10 token balance query.

**TokenValue & TokenID**
Msg.tokenvalue, represents the token value in the current msg call, with a default value of 0. Msg.tokenid, represents the token id in current msg call, with a default value of 0.


63 changes: 63 additions & 0 deletions networks/tron-network/trx-and-trc-token/trc-10/trc-10-transfer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# TRC-10 Transfer

**HTTP API:**HTTP

```text
wallet/transferasset
Description: Transfer token
demo: curl -X POST http://127.0.0.1:8090/wallet/transferasset -d '{"owner_address":"41d1e7a6bc354106cb410e65ff8b181c600ff14292", "to_address": "41e552f6487585c2b58bc2c9bb4492bc1f17132cd0", "asset_name": "31303030303031", "amount": 100}'
Parameter owner_address: Owner address, default hexString
Parameter to_address: To address, default hexString
Parameter asset_name: Token id, default hexString
Parameter amount: Token transfer amount
Parameter permission_id: Optional, for multi-signature use
Return: Transaction object
Note: The unit of 'amount' is the smallest unit of the token
```

**Tronweb Example:**JavaScript

```text
const privateKey = "...";
var toAddress = "TM2TmqauSEiRf16CyFgzHV2BVxBejY9iyR";
var tokenID= "1000088";
var amount = 1000;
var fromAddress = "TVDGpn4hCSzJ5nkHPLetk8KQBtwaTppnkr";
//Creates an unsigned TRC10 token transfer transaction
const tradeobj = await tronWeb.transactionBuilder.sendToken(
toAddress,
amount,
tokenID,
fromAddress,
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
//sign
const signedtxn = await tronWeb.trx.sign(
tradeobj,
privateKey
);
//broadcast
const receipt = await tronWeb.trx.sendRawTransaction(
signedtxn
).then(output => {
console.log('- Output:', output, '\n');
return output;
});
```

**Wallet-cli Example :**wallet-cli command

```text
#Usage : TransferAsset [OwnerAddress] ToAddress AssertID Amount
TransferAsset TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh 1000099 1000
```

Please follow the instructions below to complete this transaction:

1. Tip: "Please confirm and enter your permission id, if input y or Y means default 0, other non-numeric characters will cancel transaction.", Enter "y" or "Y" to confirm the transaction;
2. Tip: "lease choose your key for sign. ...... Please choose between 1 and 2", select the serial number of the sign account;
3. Tip: "Please input your password.", Enter your local password;
4. Tip: "TransferAsset 1000 to TWbcHNCYzqAGbrQteKnseKJdxfzBHyTfuh successful !!", which indicates that Successfully transferred TRC10 tokens.

8 changes: 8 additions & 0 deletions networks/tron-network/trx-and-trc-token/trc-20/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TRC-20

TRC‌-20 is a technical standard used for smart contracts on the TRON blockchain for implementing tokens with the TRON Virtual Machine \(TVM\). It is fully compatible with ERC‌-20.


[TRC-20 standard contract template](https://github.com/zyumingfit/TRC20-Contract-Template)


Loading

0 comments on commit 2ed742d

Please sign in to comment.