From a859a07421a71af00c2d984ddbbb776f6cf26a3e Mon Sep 17 00:00:00 2001 From: Zakaria Hossain Foysal Date: Fri, 22 Jul 2022 17:35:32 +0600 Subject: [PATCH] understanding issue fix --- token-erc-1155/README.md | 10 +++++----- token-erc-1155/chaincode-go/chaincode/contract.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/token-erc-1155/README.md b/token-erc-1155/README.md index c2a6fe74..fecc4879 100644 --- a/token-erc-1155/README.md +++ b/token-erc-1155/README.md @@ -37,7 +37,7 @@ Although Mint / Burn are not required, they are necessary to change the supply o - Burn - BurnBatch - Extra/utility functions - - BatchTransferFromMultiRecipient: This is not defined in the standard. We created this function to solve an issue we encountered. It is only required if a person wants to send tokens to multiple persons in a blockchain block. If a person doesn't use this function and create two transactions in a single block, there will be key conflicts because the chaincode will try to decrement the balance of the sender twice in a block and this causes a key conflict in Fabric [just like explained in here](https://github.com/hyperledger/fabric-samples/tree/main/high-throughput). This problem does not exist in Ethereum because, in Ethereum, the transactions are ordered before they are executed. + - BatchTransferToMultiRecipientFrom: This is not defined in the standard. We created this function to solve an issue we encountered. It is only required if a person wants to send tokens to multiple persons in a blockchain block. If a person doesn't use this function and create two transactions in a single block, there will be key conflicts because the chaincode will try to decrement the balance of the sender twice in a block and this causes a key conflict in Fabric [just like explained in here](https://github.com/hyperledger/fabric-samples/tree/main/high-throughput). This problem does not exist in Ethereum because, in Ethereum, the transactions are ordered before they are executed. - BroadcastTokenExistence: Explained in ERC-1155 but it is not required. It is only used if a token minter wants to announce the existence of a token without minting it. - ClientAccountID: This function is special for Fabric because we do not have wallet addresses in Fabric and users need to know their account ID to transfer tokens. - ClientAccountBalance: A shorthand for BalanceOf function. @@ -261,9 +261,9 @@ Send Person P2 six token3s, three token4s, and one token2s by calling BatchTrans peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n erc1155 -c "{\"function\":\"BatchTransferFrom\",\"Args\":[\"$P1\",\"$P2\",\"[3,4,2]\",\"[6,3,1]\"]}" --waitForEvent ``` -#### BatchTransferFromMultiReceipent +#### BatchTransferToMultiReceipentFrom -Call BatchTransferFromMultiReceipent as Person1 in order to send: +Call BatchTransferToMultiReceipentFrom as Person1 in order to send: - six token5s to person P3, - six token3s to person P4, - three token4s to person P2, @@ -271,7 +271,7 @@ Call BatchTransferFromMultiReceipent as Person1 in order to send: - and three token6s to person P2. ```bash -peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n erc1155 -c "{\"function\":\"BatchTransferFromMultiRecipient\",\"Args\":[\"$P1\",\"[\\\"$P3\\\",\\\"$P4\\\",\\\"$P2\\\",\\\"$P5\\\",\\\"$P2\\\"]\",\"[5,3,4,2,6]\",\"[6,6,3,2,3]\"]}" --waitForEvent +peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n erc1155 -c "{\"function\":\"BatchTransferToFromMultiRecipientFrom\",\"Args\":[\"$P1\",\"[\\\"$P3\\\",\\\"$P4\\\",\\\"$P2\\\",\\\"$P5\\\",\\\"$P2\\\"]\",\"[5,3,4,2,6]\",\"[6,6,3,2,3]\"]}" --waitForEvent ``` ### Clean up @@ -284,4 +284,4 @@ When you are finished, you can bring down the test network. This command will br ## Acknowledgement -This work has been carried out at Boğaziçi University and has received funding from the European Union’s Horizon 2020 Research and Innovation programme under Grant Agreement No. 856632. \ No newline at end of file +This work has been carried out at Boğaziçi University and has received funding from the European Union’s Horizon 2020 Research and Innovation programme under Grant Agreement No. 856632. diff --git a/token-erc-1155/chaincode-go/chaincode/contract.go b/token-erc-1155/chaincode-go/chaincode/contract.go index 2f05bdf8..6478631c 100644 --- a/token-erc-1155/chaincode-go/chaincode/contract.go +++ b/token-erc-1155/chaincode-go/chaincode/contract.go @@ -417,7 +417,7 @@ func (s *SmartContract) BatchTransferFrom(ctx contractapi.TransactionContextInte return emitTransferBatch(ctx, transferBatchEvent) } -// BatchTransferToMultiRecipient transfers multiple tokens from sender account to multiple recipient accounts +// BatchTransferToMultiRecipientFrom transfers multiple tokens from sender account to multiple recipient accounts // recipient account must be a valid clientID as returned by the ClientID() function // This function triggers a TransferBatchMultiRecipient event func (s *SmartContract) BatchTransferToMultiRecipientFrom(ctx contractapi.TransactionContextInterface, sender string, recipients []string, ids []uint64, amounts []uint64) error {