Verwenden von Smart Contract mit web3- Transaktion kann nicht erfolgreich gesendet werden

Ich habe versucht, Ether von Multiaddress zu senden, dafür habe ich einen Vertrag erstellt. Der Vertrag wird erfolgreich im Ropsten-Testnetz bereitgestellt.

Ich habe den Dienst im Hintergrund mit diesem Befehl gestartet.

parity --warp --chain ropsten --rpcapi 'eth,net,web3,personal'

Vertragscode:

pragma solidity ^0.4.20;

contract ERC20 {
  function transfer(address _recipient, uint256 _value) public returns (bool success);
}

contract Airdrop {
  function drop(ERC20 token, address[] recipients, uint256[] values) public {
    for (uint256 i = 0; i < recipients.length; i++) {
      token.transfer(recipients[i], values[i]);
    }
  }
}

Vertraglich bereitgestellte URL: https://ropsten.etherscan.io/address/0x84265173B2386D674ABA59b35D8C2A77C8A88181

Versucht, send_transaction mit Web3Js anzuwenden, aber nicht erfolgreich.

const Web3 = require('web3')
const abi = require('human-standard-token-abi') 

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));


// Define the contract addresses and the contract instance
const contractAddress = '0x84265173B2386D674ABA59b35D8C2A77C8A88181'
//const contract = new web3.eth.contract(abi, contractAddress)

var contractAbi = web3.eth.contract(abi);
var contract = contractAbi.at(contractAddress);
// suppose you want to call a function named myFunction of myContract

/*console.log(web3.eth.accounts[0]);
return false;*/

contract.drop.sendTransaction('0x627306090abaB3A6e1400e9345bC60c78a8BEf57',["0x2885f9904f3d1790ba53009bc9e0baae377d67df","0x7b7cd7d5cee9fb36b7995a3d81df0122a0b1af4a"],[100,200],{
    from:web3.eth.accounts[0],
    gas:4000000},function (error, result){ //get callback from function which is your transaction key
    if(!error){
        console.log(result);
    } else{
        console.log(error);
    }
})

Bitte lassen Sie mich wissen, was in diesen Schritten falsch ist. Was ich von meiner Seite vermisst habe. Ich kann meine Transaktion nicht mit Vertrag an Multiaddress senden.

Aktuell bekomme ich diesen Fehler:

TypeError: name.match is not a function
    at SolidityTypeAddress.isType (/var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/address.js:23:19)
    at /var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/coder.js:57:18
    at Array.filter (<anonymous>)
    at SolidityCoder._requireType (/var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/coder.js:56:36)
    at /var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/coder.js:231:21
    at Array.map (<anonymous>)
    at SolidityCoder.getSolidityTypes (/var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/coder.js:230:18)
    at SolidityCoder.encodeParams (/var/www/html/BlockChain/parity/node_modules/web3/lib/solidity/coder.js:88:30)
    at SolidityFunction.toPayload (/var/www/html/BlockChain/parity/node_modules/web3/lib/web3/function.js:92:52)
    at SolidityFunction.sendTransaction (/var/www/html/BlockChain/parity/node_modules/web3/lib/web3/function.js:163:24)

Aber ich glaube nicht, dass es am Vertrag liegt. Ich übersehe etwas oder gehe in die falsche Richtung?

Bitte helfen Sie mir dringend, damit ich meine Arbeit darauf aufbauend fortsetzen kann.

Antworten (1)

Sie sind human-standard-token-abidabei, Ihren Vertrag (der ein ERC20-Vertrag ABI ist) zu erstellen Airdrop, der eine ganz andere Funktion hat.

ABI für Airdrop-Vertrag:

[
    {
      "constant": false,
      "inputs": [
        {
          "name": "token",
          "type": "address"
        },
        {
          "name": "recipients",
          "type": "address[]"
        },
        {
          "name": "values",
          "type": "uint256[]"
        }
      ],
      "name": "drop",
      "outputs": [],
      "payable": false,
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ]

Das ist die ABI, an die Sie übergeben müssen, um web3.eth.contract(abi);Ihren Vertragsgegenstand zu instanziieren.

Hallo @Andrey, ich habe ABI wie von Ihnen angegeben geändert und es war ein festgefahrenes Sperrkonto, also habe ich es entsperrt, aber jetzt gibt es keine Ausgabe oder keine Fehlerrückgabe in der sendTransaction-Funktionalität zurück. Ich denke, dass etwas mit der sendTransaction-Funktion nicht stimmt. Können Sie das bitte einmal überprüfen? ist es richtig oder nicht?
Deine Funktion sieht gut aus. Wird die Callback-Funktion überhaupt aufgerufen? Wenn Sie, bevor if(!error)Sie eine Leitung aufbauen und anrufen console.log(result); console.log(error);, etwas ausgeben?
Ja, ich habe es überprüft, aber es wird nichts angezeigt. @Andrey
Transaktion abgeschlossen, aber es wird fehlschlagen. ropsten.etherscan.io/tx/… Warum ist es fehlgeschlagen?