3

I am trying to access the content in a file that I uploaded to Swarm using oraclize. I found a smart contract in https://github.com/oraclize/ethereum-examples/blob/master/solidity/Swarm.sol

I was just trying to print the 'hello world' (the content of the swarm hash the author specified in the contract). So, I simply mined the contract. Then used the details in the JavaScript as follows (using meteor.js):

//variables

contractAddressSwarm = "0x87b620f0731e15cb1655e216a87c986154ba4248"

ABIArraySwarm = [{"constant":false,"inputs":[{"name":"myid","type":"bytes32"},{"name":"result","type":"string"}],"name":"__callback","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"myid","type":"bytes32"},{"name":"result","type":"string"},{"name":"proof","type":"bytes"}],"name":"__callback","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"swarmContent","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"update","outputs":[],"payable":true,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"description","type":"string"}],"name":"newOraclizeQuery","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"swarmContent","type":"string"}],"name":"newSwarmContent","type":"event"}]

//Print swarm content in the console when a button is clicked

'click #buttonSwarm'(event, instance) { var template= Template.instance();

myContract = web3.eth.contract(ABIArraySwarm).at(contractAddressSwarm);

console.log("Swarm Contract execution");

myContract.swarmContent(function(err, res){ TemplateVar.set(template, "counter", res); console.log(TemplateVar.get(template,"counter")); }); },

....

But every time it is printing 'null'. What am I doing wrong in the callback?

  • I think, I am doing something wrong in the javascript callback. Can you please send me the javascript that you are using Today I found an error in the browser's javascript console as follows: >Error: Invalid JSON RPC response: "" >Stack trace: require<[26]</module.exports.InvalidResponse@192.168.1.116:3000/packages/… >require<[32]</HttpProvider.prototype.sendAsync/request.onreadystatechange@192.168.1.116:3000/packages/… I don't know what is goi – user3606212 Apr 4 '17 at 15:56
  • Welcome to Ethereum! If you have another question, please ask it by clicking the Ask Question button. – Afr Apr 4 '17 at 18:36
2

Marco from Oraclize here. The support for Swarm is experimental, so there may be some disruptions of the datasource service, as you have experienced. It is now up again and working correctly. You can test it here.

  • Hi Marco. Thanks for your response. I think I am doing something wrong in the javascript callback. Can you please send me one that you are using. – Arghya Kusum Das Apr 4 '17 at 14:40
  • Are you using a local blockchain instance (i.e like testrpc or parity/geth in dev mode) or are you on testnet/main-net? If it's the former, you need to install the ethereum-bridge in order for Oraclize to see your smart contracts and interact with your blockchain instance. You can find the ethereum-bridge here: github.com/oraclize/ethereum-bridge – Marco Giglio Apr 6 '17 at 12:01
  • I am using testnet – Arghya Kusum Das Apr 7 '17 at 0:55
  • I think it's easier if we move the discussion to our gitter channel: gitter.im/oraclize/ethereum-api?source=orgpage – Marco Giglio Apr 7 '17 at 9:00

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.