基于区块链的毕业设计Ethereum MultiSig Wallet Contract – 以太坊MultiSig钱包合同

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计Ethereum MultiSig Wallet Contract – 以太坊MultiSig钱包合同 是一篇很好的国外资料

Ethereum MultiSig Wallet Contract

About

Multi-sig contract suitable for use as a 2-of-3 multisig wallet.

The core functionality of the wallet is implemented in the WalletSimple contract. It is initialized with 3 signer addresses, two of which must participate in order to execute a transaction from the wallet. Auxillary contracts called Forwarders can be deployed with a WalletSimple contract initialized as its “parent”. Any funds that the forwarder receives will be sent on back to the parent wallet. This enables omnibus-style wallets to create many addresses that are all controlled by the same wallet.

Features of the wallet contract:

  1. Functions as a 2-of-3 multisig wallet for sending transactions.
  2. Support for synchronous (single transaction) approvals containing multiple signatures through the use of ecrecover.
  3. ERC20 tokens and ether can be sent out from the main wallet through a multisig process.
  4. ‘Safe Mode’ can be set on a wallet contract that prevents ETH and ERC20 tokens from being sent anywhere other than to wallet signers.
  5. Transactions can be sent in batches through a batch function (sendMultiSigBatch) to save on fees if a user needs to perform multiple transactions.
  6. Slightly different implementations exist for non-eth chains, which require signatures to include a networkId to protect against cross-chain replay of signatures.

Features of the forwarder contract

  1. Deployed with a single, permanent parent address.
  2. Automatically flushes any ETH received to the parent address.
  3. Able to flush ERC20 tokens received to the parent address through a separate transaction (flushForwarderTokens).

Note that this suite of contracts is an upgraded version of eth-multisig-v2. The main changes that were made are as follows:

  • Wallets and forwarders are deployed as proxy instances to a single implementation, to save on deployment fees.
  • Wallets and forwarders are deployed using CREATE2 to allow addresses to be generated on demand, but only deployed upon first use.
  • Wallets include a batch function to save on fees when sending multiple transactions.
  • SequenceId is now simply a strictly increasing nonce.

Deployment

The Wallet contract and forwarder contracts can each be deployed independently of each other, using the provided ForwarderFactory and WalletFactory. These factories employ two features to minimize the cost associated with deploying a new contract:

  • Minimal proxy – Each deployed contract is simply a tiny contract which proxies calls to use the logic of a single implementation contract.
  • CREATE2 – Contracts are deployed with the CREATE2 opcode to allow users to distribute contract addresses and only deploy them upon first use.

Wallets To deploy wallets, follow these steps:

  1. Deploy a wallet contract (contracts/WalletSimple.sol) with any address. Take note of the wallet’s address.
  2. Deploy a WalletFactory contract (contracts/WalletFactory.sol) with any address. Use the address of the contract deployed in step 1 as the _implementationAddress parameter.
  3. Call the createWallet function on the factory deployed in step 2. Provide the list of signers on the wallet, and some “salt” which will be used to determine the wallet’s address via CREATE2.
  4. Check for the WalletCreated event from the above transaction. This will include your newly generated wallet address

Forwarders To deploy forwarders, follow these steps:

  1. Deploy a forwarder contract (contracts/Forwarder.sol) with any address. Take note of the contract’s address.
  2. Deploy a ForwarderFactory contract (contracts/ForwarderFactory.sol) with any address. Use the address of the contract deployed in step 1 as the _implementationAddress parameter.
  3. Call the createForwarder function on the factory deployed in step 2. Provide the parent address, and some “salt” which will be used to determine the forwarder’s address via CREATE2.
  4. Check for the ForwarderCreated event from the above transaction. This will include your newly generated forwarder address

Contracts

Brief descriptions of the various contracts provided in this repository.

WalletSimple

The multi-sig wallet contract. Initializes with three signers and requires authorization from any two of them to send a transaction.

Forwarder

Forwarder function. Initializes with a parent to which it will forward any ETH that it receives. Also has a function to forward ERC20 tokens.

WalletFactory

Factory to create wallets. Deploys a small proxy which utilizes the implementation of a single wallet contract.

ForwarderFactory

Factory to create forwarder. Deploys a small proxy which utilizes the implementation of a single forwarder contract.

Batcher

Transfer batcher. Takes a list of recipients and amounts, and distributes ETH to them in a single transaction.

Installation

NodeJS 8.14.0 is recommended.

npm install

This installs truffle and an Ethereum test RPC client.

Wallet Solidity Contract

Find it at contracts/WalletSimple.sol

Running tests

A test suite is included through the use of the truffle framework, providing coverage for methods in the wallet.

The truffle framework will depend on the Web3 interface to a local Web3 Ethereum JSON-RPC. If you’ve followed the above steps, run the following to start testrpc.

npm run truffle-testrpc

You should verify that you are not already running geth, as this will cause the tests to run against that interface.

In a separate terminal window, run the following command to initiate the test suite, which will run against the RPC:

npm run truffle-test

Notes

  • wallet creation salt should include [a hash of] the signers associated with the wallet.
  • forwarder creation salt should include [a hash of] the parentAddress.

以太坊ethMultiSig Wallet Contract

关于部署

Contracts

安装

Wallet Solidity Contract

运行测试

说明

  • 用作发送事务的三取二MultiSig Wallet。
  • 通过使用ecrecover支持包含多个签名的同步(单笔交易)审批。
  • ERC20代币和以太可以通过multisig流程从主钱包发出。
  • 可以在钱包合同上设置“安全模式”,防止ETH和ERC20代币被发送到钱包签名者以外的任何地方。
  • 如果用户需要执行多个事务,可以通过批处理功能(sendMultiSigBatch)批量发送事务,以节省费用。
  • 非eth链的实现略有不同,要求签名包含networkId以防止签名跨链重放。
  • 使用一个永久父地址部署。
  • 自动将接收到的任何ETH刷新到父地址。
  • 能够通过单独的事务(flushForwarderTokens)将接收到的ERC20令牌刷新到父地址。
  • 钱包和转发器作为代理实例部署到单个实现中,以节省部署费用。
  • 钱包和转发器使用CREATE2进行部署,允许按需生成地址,但仅在首次使用时部署。
  • 钱包具有批量功能,可在发送多笔交易时节省费用。
  • SequenceId现在只是一个严格递增的nonce。
  • 最小代理-每个部署的契约只是一个微小的契约,代理调用以使用单个实现契约的逻辑。
  • CREATE2-契约与CREATE2操作码一起部署,允许用户分发契约地址,并且只在首次使用时部署它们。
  • 部署钱包合同/钱包简单.sol)任何地址。记下钱包的地址。
  • 部署WalletFactory合同/Wallet工厂.sol)任何地址。使用步骤1中部署的协定的地址作为u implementationAddress参数。
  • 在步骤2中部署的工厂上调用createWallet函数。提供钱包上的签名者列表,以及一些“salt”,它们将用于通过CREATE2确定钱包的地址。
  • 检查上述事务中的WalletCreated事件。这将包括您新生成的钱包地址
  • 部署转发商合同/转发器.sol)任何地址。记下合同的地址。
  • 部署ForwarderFactory合同/货代工厂.sol)任何地址。使用步骤1中部署的协定的地址作为u implementationAddress参数。
  • 在步骤2中部署的工厂上调用createForwarder函数。提供父地址和一些“salt”,它们将用于通过CREATE2确定转发器的地址。
  • 检查上述事务中的ForwarderCreated事件。这将包括您新生成的转发器地址
  • 钱包创建地址应包括[哈希]与钱包相关的签名者。
  • 转发器创建salt应包括parentAddress的[哈希]。你知道吗
  • Multi-sig合同适合用作3取2 multisig钱包。

    钱包的核心功能在WalletSimple合同中实现。它由3个签名者地址初始化,其中两个必须参与才能从钱包执行交易。称为转发器的辅助契约可以与初始化为“父”的WalletSimple契约一起部署。转发商收到的任何资金都将被送回母公司的钱包。这使得综合式钱包可以创建多个地址,这些地址都由同一个钱包控制。

    钱包合同的特点:

    1. 用作发送事务的三取二MultiSig Wallet。
    2. 通过使用ecrecover支持包含多个签名的同步(单笔交易)审批。
    3. ERC20代币和以太可以通过multisig流程从主钱包发出。
    4. 可以在钱包合同上设置“安全模式”,防止ETH和ERC20代币被发送到钱包签名者以外的任何地方。
    5. 如果用户需要执行多个事务,可以通过批处理功能(sendMultiSigBatch)批量发送事务,以节省费用。
    6. 非eth链的实现略有不同,要求签名包含networkId以防止签名跨链重放。

    货代合同的特点

    1. 使用一个永久父地址部署。
    2. 自动将接收到的任何ETH刷新到父地址。
    3. 能够通过单独的事务(flushForwarderTokens)将接收到的ERC20令牌刷新到父地址。

    请注意,这套合同是eth-multisig-v2的升级版本。所做的主要更改如下:

    • 钱包和转发器作为代理实例部署到单个实现中,以节省部署费用。
    • 钱包和转发器使用CREATE2进行部署,允许按需生成地址,但仅在首次使用时部署。
    • 钱包具有批量功能,可在发送多笔交易时节省费用。
    • SequenceId现在只是一个严格递增的nonce。

    Contracts

    可以使用提供的ForwardFactory和WalletFactory分别独立部署Wallet合同和forwarder合同。这些工厂使用两个功能来最小化与部署新合同相关的成本:

    • 最小代理-每个部署的契约只是一个微小的契约,代理调用以使用单个实现契约的逻辑。
    • CREATE2-契约与CREATE2操作码一起部署,允许用户分发契约地址,并且只在首次使用时部署它们。

    钱包要部署钱包,请执行以下步骤:

    1. 部署钱包合同/钱包简单.sol)任何地址。记下钱包的地址。
    2. 部署WalletFactory合同/Wallet工厂.sol)任何地址。使用步骤1中部署的协定的地址作为u implementationAddress参数。
    3. 在步骤2中部署的工厂上调用createWallet函数。提供钱包上的签名者列表,以及一些“salt”,它们将用于通过CREATE2确定钱包的地址。
    4. 检查上述事务中的WalletCreated事件。这将包括您新生成的钱包地址

    转发器要部署转发器,请执行以下步骤:

    1. 部署转发商合同/转发器.sol)任何地址。记下合同的地址。
    2. 部署ForwarderFactory合同/货代工厂.sol)任何地址。使用步骤1中部署的协定的地址作为u implementationAddress参数。
    3. 在步骤2中部署的工厂上调用createForwarder函数。提供父地址和一些“salt”,它们将用于通过CREATE2确定转发器的地址。
    4. 检查上述事务中的ForwarderCreated事件。这将包括您新生成的转发器地址

    安装

    此存储库中提供的各种合同的简要说明。

    钱包简单

    多签名钱包合同。使用三个签名者初始化,并需要其中任意两个签名者的授权才能发送事务。

    转发器

    转发器功能。用父级初始化,它将接收到的任何ETH转发给该父级。还具有转发ERC20令牌的功能。

    钱包工厂

    创建钱包的工厂。部署一个小型代理,利用单个钱包契约的实现。

    转发器工厂创建转发器的工厂。部署一个小型代理,它利用单个转发器契约的实现。

    分批器

    转移分批器。获取收件人和金额的列表,并在单个事务中将ETH分发给他们。

    建议使用NodeJS 8.14.0。

    Wallet Solidity Contract

    这将安装truffle和以太坊eth测试RPC客户端。

    npm install

    在合同处找到/钱包简单.sol

    运行测试

    通过使用truffle框架包括一个测试套件,为钱包中的方法提供覆盖范围。

    说明

    truffle框架将依赖于与本地Web3以太坊ethJSON-RPC的Web3接口。如果您遵循了上述步骤,请运行以下命令来启动testrpc。

    您应该确认尚未运行geth,因为这将导致测试针对该接口运行。

    npm run truffle-testrpc

    在单独的终端窗口中,运行以下命令以启动测试套件,它将运行在RPC上:

    In a separate terminal window, run the following command to initiate the test suite, which will run against the RPC:

    npm run truffle-test

    Notes

    • 钱包创建地址应包括[哈希]与钱包相关的签名者。
    • 转发器创建salt应包括parentAddress的[哈希]。你知道吗

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

    www.interchains.cc

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

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计Ethereum MultiSig Wallet Contract – 以太坊MultiSig钱包合同

    提供最优质的资源集合

    立即查看 了解详情