Is the ipfs hash stored anywhere on the market contract?

gnosis.contracts.Market.at(marketaddress) gives me the market contract and gnosis.loadEventDescription(‘QmN…’) gives me the event details, but is there anyway to derive the ipfs if I only have access to the market address?

Hey joshpitzalis,

The IPFS hash is stored on the Oracle.
In order to get the ipfsHash related with an Oracle used by a Market’s Event, you need to follow the following steps:
From a market instance, get the event related to the market
From the event instance, get the oracle related to the event
From the oracle you can finally get the ipfsHash

For instance, the code below follows the steps discussed above which would allow you to get an ipfsHash starting from a market address:

const Gnosis = require(’@gnosis.pm/pm-js’)
const Web3 = require(‘web3’)

const provider = new Web3.providers.HttpProvider(‘https://rinkeby.infura.io’)
Const marketAddress = 0xe3f8f1c5102c016710bb1028e27e0ca7e268d638
let gnosis

Gnosis.create({ ethereum: provider }).then(result => {
    gnosis = result
    // Get market contract instance
    const market = gnosis.contracts.Market.at(marketAddress)
    // Get event address related to the market
    market.eventContract().then(eventAddress => {
      // Get event contract instance
      const event = gnosis.contracts.Event.at(eventAddress)
      // Get oracle address related to the event
      event.oracle().then(oracleAddress => {
        // Get oracle contract instance
        const oracle = gnosis.contracts.CentralizedOracle.at(oracleAddress)
        // Get ipfsHash address
        oracle.ipfsHash().then(ipfsHashHex => {
          // Ipfs hash is on hex format, convert it to utf8
          const ipfsHash = Buffer.from(ipfsHashHex.replace('0x', ''), 'hex').toString('utf8')
          console.log(ipfsHash)
        })
      })
    })
})

Another solution would be executing an HTTP GET request to a running TradingDB server. It would return a JSON containing all the market information, including the event and oracle info.
For example, accordingly to the Javascript code above, you could easily achieve the same information by calling:
https://gnosisdb.rinkeby.gnosis.pm/api/markets/0xe3f8f1c5102c016710bb1028e27e0ca7e268d638/