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?

2
  • 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 Apr 4, 2017 at 15:56
  • Welcome to Ethereum! If you have another question, please ask it by clicking the Ask Question button.
    – q9f
    Apr 4, 2017 at 18:36

1 Answer 1

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.

4
  • 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. Apr 4, 2017 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
    – user34
    Apr 6, 2017 at 12:01
  • I am using testnet Apr 7, 2017 at 0:55
  • I think it's easier if we move the discussion to our gitter channel: gitter.im/oraclize/ethereum-api?source=orgpage
    – user34
    Apr 7, 2017 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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