It's time to build and customizing your own Polywrapper! We'll be adding IPFS support to the SimpleStorage Polywrap.
A complete project with the modifications described below can be found here.
The first step to adding new Polywrapper functionality is defining the method we want our users to query in GraphQL. Add the following method & custom data types to your
./src/mutation/schema.graphql schema file:
Since we'll be making use of IPFS in our Polywrapper, let's import its
Mutation type so we can call it from our code, allowing us to upload content:
./src/mutation/index.ts file, import the new types we've defined:
These new types will not exist yet, but don't worry, they'll be generated in the
./src/mutation/w3/* folder once the
yarn build command is run.
Next, we'll implement the
setIpfsData mutation method. Add this function to the bottom of your
As you can see, the
SimpleStorage.sol smart contract already exposes a
Ethereum_Mutation.callContractMethodAndWait function also accepts an optional argument,
connection. This option allows you to select the network in which you're transacting with, by specifying a node's endpoint, or a network (name or chain ID) (e.g.
To verify everything is implemented correctly, try running
yarn build and see if the Polywrap build succeeds.