Generate an RPC Proxy Postman Collection with the Command Line
You can automatically create a Postman collection for a deployed package’s token and account/identity ABIs.
The generate-rpc-proxy-postman Hardhat task generates a Postman collection for an Oracle Blockchain Platform RPC proxy from account and token contract artifacts. The generated collection contains the proxy requests derived from both ABIs.
hardhat.config.ts file imports the generate-rpc-proxy-postman task. Generated projects typically include the following line. import "./tasks/generate-rpc-proxy-postman";There must be one account artifact and one token artifact to run the task. Locate the artifact files under the artifacts/ folder, and then use their full or project-relative paths in the command.
To generate a Postman collection, run the task with the two artifact paths an an output path, as shown in the following example. Replace the example artifact paths and output filename with those for your project. The output directory is created when necessary.
npx hardhat generate-rpc-proxy-postman \
--account-abi artifacts/contracts/Account.sol/Account.json \
--token-abi artifacts/contracts/Token.sol/Token.json \
--out generated/rpc-proxy-postman/token-rpc-proxy.postman.collection.jsonDo not manually edit the collection. If the ABI changes, regenerate the collection.
To use the generated collection, complete the following steps.
- In Postman, select Import and choose the generated
.postman.collection.jsonfile. - Select or create an environment that supplies the RPC proxy base URL and its authentication values.
- Review the collection variables and request bodies before sending a transaction. Values such as contract address, signer, and method arguments are environment- or request-specific.
Troubleshooting
| Condition | Resolution |
|---|---|
| Task not found | Confirm that the hardhat.config.ts file imports ./tasks/generate-rpc-proxy-postman, then run the command again from the project root.
|
| Artifact file not found | Run the project’s compile command and verify the paths under artifacts/ folder. Supply the contract artifact JSON, not the source .sol file.
|
| The collection does not include a method | Confirm the method is present in the account or token artifact ABI, then regenerate the collection. |
| Postman request is unauthorized or cannot reach the proxy | This is an environment configuration issue after collection generation. Verify the selected Postman environment’s proxy URL and authentication values. |