教你一招 如何批量发送eth 或者代币

时间:2024-03-17 21:01:49

 

批量发送以太坊 部署下面的合约 然后往下面的合约打币 就可以分发

 

  1. pragma solidity ^0.4.21;
  2.  
  3. contract batchTransfer {
  4.  
  5. address[] public myAddresses = [
  6.  
  7. 0xcD2CAaae37354B7549aC7C526eDC432681821bbb,
  8.  
  9. 0x8948e4b00deb0a5adb909f4dc5789d20d0851d71,
  10.  
  11. 0xce82cf84558add0eff5ecfb3de63ff75df59ace0,
  12.  
  13. 0xa732e7665ff54ba63ae40e67fac9f23ecd0b1223,
  14.  
  15. 0x445b660236c39f5bc98bc49dddc7cf1f246a40ab,
  16.  
  17. 0x60e31b8b79bd92302fe452242ea6f7672a77a80f
  18.  
  19. ];
  20.  
  21.  
  22.  
  23. function () public payable {
  24.  
  25. require(myAddresses.length>0);
  26.  
  27. uint256 distr = msg.value/myAddresses.length;
  28.  
  29. for(uint256 i=0;i<myAddresses.length;i++)
  30.  
  31. {
  32.  
  33. myAddresses[i].transfer(distr);
  34.  
  35. }
  36.  
  37. }
  38.  
  39. }

例子 https://ropsten.etherscan.io/tx/ ... c96509c5cfe2dfd6394

批量发送代币 发布一下合约 即可实现

 

  1. pragma solidity ^0.4.0;
  2.  
  3. contract demo{
  4.     
  5.     function transfer(address from,address caddress,address[] _tos,uint v)public returns (bool){
  6.         require(_tos.length > 0);
  7.         bytes4 id=bytes4(keccak256("transferFrom(address,address,uint256)"));
  8.         for(uint i=0;i<_tos.length;i++){
  9.             caddress.call(id,from,_tos[i],v);
  10.         }
  11.         return true;
  12.     }
  13. }

例子 https://ropsten.etherscan.io/tx/ ... 39e7dfb66dfa61acfdb

有不懂的加群 

教你一招 如何批量发送eth 或者代币