{"action":"created","issue":{"url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/35","repository_url":"https://api.github.com/repos/eris-ltd/eris-contracts.js","labels_url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/35/comments","events_url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/35/events","html_url":"https://github.com/eris-ltd/eris-contracts.js/issues/35","id":168643652,"number":35,"title":"Transferring tokens from one user address to another","user":{"login":"getsachmail","id":6228470,"avatar_url":"https://avatars.githubusercontent.com/u/6228470?v=3","gravatar_id":"","url":"https://api.github.com/users/getsachmail","html_url":"https://github.com/getsachmail","followers_url":"https://api.github.com/users/getsachmail/followers","following_url":"https://api.github.com/users/getsachmail/following{/other_user}","gists_url":"https://api.github.com/users/getsachmail/gists{/gist_id}","starred_url":"https://api.github.com/users/getsachmail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getsachmail/subscriptions","organizations_url":"https://api.github.com/users/getsachmail/orgs","repos_url":"https://api.github.com/users/getsachmail/repos","events_url":"https://api.github.com/users/getsachmail/events{/privacy}","received_events_url":"https://api.github.com/users/getsachmail/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-01T13:18:15Z","updated_at":"2016-10-17T19:21:13Z","closed_at":"2016-10-17T19:21:13Z","body":"when we are using address.send(uint param) in Solidity it is transferring one token from address (given at time of eris pkg do --address param value i.e. -the account from where we deploy the contract) to the deployed contract's address, irresepective of any amount, it only transfers one token. \r\n\r\n\r\n<<<<<<<<<<<<<<<<<<<<<<<<tran.sol>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\ncontract tran {\r\n\r\n    function transfer(address ge, uint amount) returns (bool result) \r\n    {\r\n        return ge.send(msg.value);\r\n    }    \r\n\r\n    function getBalance() returns (uint bal) \r\n    {\r\n        return this.balance; // balance is \"inherited\" from the address type\r\n    }    \r\n}\r\n\r\n\r\n<<<<<<<<<<<<<<<<<<<<<<<<app.js>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\nvar fs = require ('fs');\r\nvar binstring = require('binstring');\r\n\r\n// Get 'eris-contracts'. \r\nvar erisContracts = require('eris-contracts');\r\n \r\n// Get 'eris-db' (the javascript API for eris-db) \r\nvar erisdbModule = require(\"eris-db\");\r\n \r\n var erisdbURL = \"http://192.168.99.100:1337/rpc\";\r\n\r\n// Create a new instance of ErisDB that uses the given URL. \r\nvar erisdb = erisdbModule.createInstance(erisdbURL);\r\n// The private key. \r\n//var accountData = require('/some/account/data.json');\r\nvar accountData = require('./accounts.json');\r\n \r\n// Create a new pipe.  \r\nvar pipe = new erisContracts.pipes.DevPipe(erisdb, accountData.simplechain_full_000);\r\n\r\npipe.addAccount(accountData.simplechain_root_000);\r\npipe.addAccount(accountData.simplechain_root_001);\r\n\r\nvar contractManager = erisContracts.newContractManager(pipe);\r\n\r\nvar contractData = require('./epm.json');\r\nvar idisContractAddress = contractData[\"deployStorageK\"];\r\nvar myJsonAbi  = JSON.parse(fs.readFileSync(\"./abi/\" + idisContractAddress));\r\nvar myContractFactory = contractManager.newContractFactory(myJsonAbi);\r\n\r\nmyContractFactory.at(idisContractAddress, function(error, contract){\r\n    if(error) {throw error}\r\n    myContract = contract;\r\n    //console.log(myContract);\r\n}); \r\n\r\n\r\n    myContract.getBalance(function(error, result)\r\n    {\r\n        if(error)\r\n        {\r\n            throw error;\r\n        }\r\n        console.log(\"Before Contract address account balance\");\r\n        console.log(result);\r\n    });\r\n\r\n    myContract.transfer(\"ED6469F715EA4E99427402FEA1E45544C814E3A0\", 1000000,function(error, result)\r\n    {\r\n        if(error)\r\n        {\r\n            throw error;\r\n        }\r\n        console.log(\"Before Contract address account balance\");\r\n        console.log(result);\r\n    });    \r\n\r\n    myContract.getBalance(function(error, result)\r\n    {\r\n        if(error)\r\n        {\r\n            throw error;\r\n        }\r\n        console.log(\"After Contract address account balance\");\r\n        console.log(result);\r\n    });\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/comments/254306225","html_url":"https://github.com/eris-ltd/eris-contracts.js/issues/35#issuecomment-254306225","issue_url":"https://api.github.com/repos/eris-ltd/eris-contracts.js/issues/35","id":254306225,"user":{"login":"NodeGuy","id":2148537,"avatar_url":"https://avatars.githubusercontent.com/u/2148537?v=3","gravatar_id":"","url":"https://api.github.com/users/NodeGuy","html_url":"https://github.com/NodeGuy","followers_url":"https://api.github.com/users/NodeGuy/followers","following_url":"https://api.github.com/users/NodeGuy/following{/other_user}","gists_url":"https://api.github.com/users/NodeGuy/gists{/gist_id}","starred_url":"https://api.github.com/users/NodeGuy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NodeGuy/subscriptions","organizations_url":"https://api.github.com/users/NodeGuy/orgs","repos_url":"https://api.github.com/users/NodeGuy/repos","events_url":"https://api.github.com/users/NodeGuy/events{/privacy}","received_events_url":"https://api.github.com/users/NodeGuy/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T19:21:13Z","updated_at":"2016-10-17T19:21:13Z","body":"There are many reasons why this is failing.  Here are the first three I see:\r\n\r\n- `getBalance` should be declared `constant`:\r\n\r\n```Solidity\r\nfunction getBalance() constant returns (uint bal) \r\n{\r\n    return this.balance; // balance is \"inherited\" from the address type\r\n}\r\n```\r\n\r\nThe `transfer` function is ignoring the `amount` argument.  Did you mean to write this?\r\n\r\n```Solidity\r\nfunction transfer(address ge, uint amount) returns (bool result) \r\n{\r\n    return ge.send(amount);\r\n}\r\n```\r\n\r\nYour asynchronous JavaScript functions are executing synchronously.  They should be written like this instead:\r\n\r\n```JavaScript\r\n      myContract.getBalance(function(error, result)\r\n      {\r\n          if(error)\r\n          {\r\n              throw error;\r\n          }\r\n          console.log(\"Before Contract address account balance\");\r\n          console.log(result);\r\n\r\n          myContract.transfer(\"ED6469F715EA4E99427402FEA1E45544C814E3A0\", 1000000,function(error, result)\r\n          {\r\n              if(error)\r\n              {\r\n                  throw error;\r\n              }\r\n              console.log(\"Before Contract address account balance\");\r\n              console.log(result);\r\n\r\n              myContract.getBalance(function(error, result)\r\n              {\r\n                  if(error)\r\n                  {\r\n                      throw error;\r\n                  }\r\n                  console.log(\"After Contract address account balance\");\r\n                  console.log(result);\r\n              });\r\n          })\r\n      })\r\n```\r\n\r\nI'm closing this issue because it's not pinpointing a bug in our code.  Feel free to re-open it if you find a bug after fixing your own.\r\n"}}
{"actor":{"display_login":"NodeGuy"}}