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.
pm-js into your project as a dependency using:
npm install --save '@gnosis.pm/pm-contracts' '@gnosis.pm/pm-js'
Be sure to issue this command with this exact spelling. The quotes are there in case you use Powershell.
node_modules directory. The
@gnosis.pm/pm-js package contains the following:
- ES6 source of the library in
srcwhich can also be found on the repository
- Compiled versions of the modules which can be run on Node.js in the
- Webpacked standalone
gnosis-pm[.min].jsfiles ready for use by web clients in the
- API documentation in the
Notice that the library refers to the
dist/index module as the
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('@gnosis.pm/pm-js')
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('.')
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> <script> // Gnosis should be available as a global after the above script import, so this subsequent script tag can make use of the API. </script>
After opening the page, the browser console can also be used to experiment with the API.