Decentralized Commerce Smart Contract – 分散商务智能合约区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Decentralized Commerce Smart Contract – 分散商务智能合约区块链毕设代写 是一篇很好的国外资料

Decentralized Commerce Smart Contract

The Boson.sol contract can be found in the test folder. It is a simple contract which uses fungible ERC20 tokens as the payment mechanism, which can be exchanged for ether on the smart contract itself. These tokens can then be used to secure a product, which is represented through a _tokenID which points to a struct with its descriptive features (price, seller, state etc.). In this way, the product itself is represented in a Non-fungible Token manner, as each tokenID is unique. If the buyer purchases a product, they send the tokens to the smart contract where they are held in ‘escrow. However, they are also then approved by the smart contract to send these tokens back to themselves or the seller. This is done through the erc20 _approve and transferFrom functions. The _approve function is an internal function, so it can only be used inside one of our functions, assuring that only in the right scenarios people can transfer the correct amount of tokens from the smart contract to the seller, or back to themselves. For the sake of the exercise i did not make any modifications to the ERC20 contract, however, it would be advisable to make the transferFrom function internal, as a buyer could transfer the tokens back to themselves, without changing the state of the order to COMPLAINT. It must also be noted that in the current format of this contract the buyer holds an asymmetric amount of power as they are the sole entity with control over the money held in escrow.

Steps to run

  1. git clone https://github.com/ILoomans/Boson.git
  2. cd Boson
  3. npm i -g truffle
  4. npm i -g ganache-cli
  5. ganache-cli
  6. Open new terminal
  7. truffle test

fixed readme


去中心化商务智能合约

那个玻色子溶胶合同可以在测试文件夹中找到。这是一个简单的合同,使用可替代的ERC20代币作为支付机制,可以在智能合同本身上兑换乙醚。然后可以使用这些令牌来保护产品,该产品通过指向具有描述性特征(价格、卖方、状态等)的结构的u tokenID来表示。通过这种方式,产品本身以不可替换的令牌方式表示,因为每个令牌ID都是唯一的。如果买家购买了产品,他们会将代币发送到智能合约,代管代币。但是,智能合约也会批准他们将这些代币发送回自己或卖家。这是通过erc20U approve和transferFrom功能完成的。u approve函数是一个内部函数,因此它只能在我们的一个函数中使用,以确保只有在正确的情况下,人们才能将正确数量的代币从智能合约转移到卖家,或转移回他们自己。为了行使我没有作出任何修改的ERC20合同,但是,它是可取的,使转让功能内部,作为一个买家可以转让代币回自己,而不改变国家的秩序投诉。还必须注意的是,在本合同的现行格式中,买方拥有不对称的权力,因为他们是唯一控制托管资金的实体。

运行步骤

  1. git克隆https://github.com/ILoomans/Boson.git
  2. cd玻色子
  3. npm i-g块菌
  4. npm i-g ganache cli
  5. ganache cli
  6. 打开新终端
  7. 块菌测试

fixed readme

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/20465.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Decentralized Commerce Smart Contract – 分散商务智能合约区块链毕设代写

提供最优质的资源集合

立即查看 了解详情