2

Currently i have

private abiToken: [ { "constant": true, "inputs": any, "name": "name", "outputs": [ { "name": "", "type": "string", "value": "ThankYou" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "_giver", "type": "address" } ], "name": "totalEtherGivenOf", "outputs": [ { "name": "numberOfEther", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": any, "name": "decimals", "outputs": [ { "name": "", "type": "uint8", "value": "0" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_to", "type": "address" } ], "name": "createTokenProxy", "outputs": [ { "name": "success", "type": "bool" } ], "payable": true, "type": "function" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address" } ], "name": "presentToken", "outputs": [ { "name": "success", "type": "bool" } ], "payable": true, "type": "function" }, { "constant": true, "inputs": [ { "name": "_giver", "type": "address" } ], "name": "etherGivenInMonth", "outputs": [ { "name": "numberOfEther", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "_receiver", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "token", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": any, "name": "symbol", "outputs": [ { "name": "", "type": "string", "value": "ThankYou" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": any, "name": "price", "outputs": [ { "name": "", "type": "uint256", "value": "5000000000000000000" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transfer", "outputs": any, "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "_receiver", "type": "address" } ], "name": "tokenReceivedInMonth", "outputs": [ { "name": "token", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "inputs": [ { "name": "_tokenName", "type": "string", "index": 0, "typeShort": "string", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;token Name", "template": "elements_input_string", "value": "ThankYou" }, { "name": "_tokenSymbol", "type": "string", "index": 1, "typeShort": "string", "bits": "", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;token Symbol", "template": "elements_input_string", "value": "ThankYou" }, { "name": "_tokenPrice", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "&thinsp;<span class=\"punctuation\">_</span>&thinsp;token Price", "template": "elements_input_uint", "value": "5" } ], "payable": false, "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "_from", "type": "address" }, { "indexed": true, "name": "_to", "type": "address" }, { "indexed": false, "name": "_value", "type": "uint256" } ], "name": "Transfer", "type": "event" } ];`

on the service i test the function in my contract that deployed on blockchain by calling the function :

testTY_Token(){

    this.connectToNode();
    let token_TY = this.web3.eth.contract(this.abiToken).at("0x28a5296F54E68DCDb7502E49a86195555Bae21F0");
    let address_from = this.web3.eth.accounts[0];
    let address_to = "0xf8f62dB380b34A77F162e485fDf881140b6f23fE";
    let amount = 5;
    token_TY.presentToken(address_to, {from: address_from, value: this.web3.toWei(amount, "ether")}, function (error, transactionHash) {
      if (error) {
        console.log(error);
      }
      return transactionHash;
    });
  }

on console log at debug mode i got error at the line let token_TY = this.web3.eth.contract(this.abiToken).at("0x28a5296F54E68DCDb7502E49a86195555Bae21F0");

ERROR TypeError: Cannot read property 'filter' of undefined
    at u (eval at webpackJsonp.97.module.exports (addScript.js:9), <anonymous>:1:25611)
    at p.at (eval at webpackJsonp.97.module.exports (addScript.js:9), <anonymous>:1:27430)
    at EthereumServices.webpackJsonp.264.EthereumServices.testTY_Token (ethereum-service.ts:161)
    at MyProfileComponent.webpackJsonp.261.MyProfileComponent.testTY (myprofile.component.ts:30)
    at Object.eval [as handleEvent] (MyProfileComponent.html:80)
    at handleEvent (core.es5.js:11914)
    at callWithDebugContext (core.es5.js:13206)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:12794)
    at dispatchEvent (core.es5.js:8814)
    at core.es5.js:9406

I'm using metamask provider that initially injected.

Some body can help to point out where i'm wrong ?

Thank you very much

1

This is because your declaration should use = not :

Change to:

private abiToken = [ { "constant": ... } ];`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.