The pm-js library offers a convenient way of accesing the Gnosis contracts for prediction markets with Javascript and Node.js. We recommend the use of pm-scripts for the creation of markets and pm-js for dealing with the automated market maker functions: BUY and SELL shares*. For interacting with the oracle contracts you might want to use it directly but pm-js allows to do it with some validation layers that are useful.

The use of pm-js assumes that you have a basic understanding of Web3.js interface. It also uses IPFS for publishing and retrieving event data, and so it will also have to be connected to an IPFS node.


Install pm-contracts and pm-js into your project as a dependency using:

   npm install --save '' ''

Be sure to issue this command with this exact spelling. The quotes are there in case you use Powershell.

This command installs the Gnosis core contracts and the Gnosis JavaScript library, and their dependencies into the node_modules directory. The package contains the following:

  • ES6 source of the library in src which can also be found on the repository
  • Compiled versions of the modules which can be run on Node.js in the dist directory
  • Webpacked standalone gnosis-pm[.min].js files ready for use by web clients in the dist directory
  • API documentation in the docs directory

Notice that the library refers to the dist/index module as the package.json main. This is because even though Node.js does support many new JavaScript features, ES6 import support is still very much in development yet (watch this page), so the modules are transpiled with Babel for Node interoperability.

In the project directory, you can experiment with the Gnosis API by opening up a node shell and importing the library like so:

const Gnosis = require('')

This will import the transpiled library through the dist/index entry point, which exports the Gnosis class.

If you are playing around with pm-js directly in its project folder, you can import it from dist

const Gnosis = require('.')

Browser use

The gnosis-pm.js file and its minified version gnosis-pm.min.js are self-contained and can be used directly in a webpage. For example, you may copy gnosis-pm.min.js into a folder or onto your server, and in an HTML page, use the following code to import the library:

<script src="gnosis-pm.min.js"></script>
// Gnosis should be available as a global after the above script import, so this subsequent script tag can make use of the API.

After opening the page, the browser console can also be used to experiment with the API.