Prerequisites
What you get and what you need
Provided by HashNut
| Item | Purpose |
|---|---|
| HashNut MPC Client | Deploy split contracts, manage their receipt addresses, aggregate funds, withdraw funds |
| HashNut Dashboard | Create and manage orders, maintain API keys, alert email and other merchant settings |
- The dashboard can also deploy split contracts, aggregate and withdraw funds, but we recommend doing those operations from the HashNut MPC Client.
What you need to prepare
| Item | Purpose |
|---|---|
| A PC | Running Windows or macOS, used to run the HashNut MPC Client. |
| A crypto wallet | With enough gas for every chain you want to accept. For example, to accept ETH and TRON the wallet needs enough ETH and TRX. |
| A browser wallet extension | HashNut currently supports ETH, BSC, POLYGON and TRON. For the EVM chains (ETH, BSC, POLYGON) install MetaMask; for TRON install TronLink. |
| A stable network | Able to reach the HashNut domains hashnut.io and defi.hashnut.io. |
| A server | With a public IP or domain that the HashNut backend can reach. |
NOTE
The "server must be publicly reachable" requirement comes from notifyUrl: once an order is paid, HashNut's server calls you, so that address has to be reachable from the internet.
The other parameter, callbackUrl, is only a browser redirect and does not need to be publicly reachable — a localhost address is fine. The two point in opposite directions, which is the single most common mix-up when integrating. See 1.3 Filling in the one-key setup parameters.
If you do not have a public server yet during local development, a tunnel will do — ngrok, frp, Cloudflare Tunnel, it makes no difference to HashNut. See Appendix: Making notifyUrl publicly reachable for a worked example.
NOTE
The screenshots in this section are taken from the Chinese UI of the MPC Client, which is the only language it currently ships with. The layout and the position of every button are identical in all languages, so you can follow along. They will be replaced once the client is localised.
The steps involved
Integrating with HashNut takes the following steps. Steps 1–4 are done in one shot by the one-key setup feature of the HashNut MPC Client; step 5 is done by its batch address creation feature.
1. Deploy the split contract
The split contract clears and settles the merchant's assets.
2. Activate the split contract
Activation assigns the contract a role called Split Wallet Manager (Wallet Manager for short), whose private key is generated jointly by HashNut and the merchant through MPC. Only after activation can receipt addresses be added and the logic contract be upgraded.
3. Generate receipt addresses for the split contract
Receipt addresses are what your customers pay into.
4. Create an API key
With this API key your server can create, query and cancel orders, and receive HashNut's callback notifications.
5. Add enough receipt addresses
If you need more receipt addresses, keep creating them for the same split contract.
Recommended path to production
To be safe, we recommend going to production in this order.
1. One-key setup
- Use the one-key setup feature of the HashNut MPC Client to create the API key, the split contract and a small number of receipt addresses (5 to start with).
2. Verify the account
- Verify the split contract. Use the dashboard or the demo shop to create several small orders (as little as 0.01), pay them, then aggregate and withdraw the funds to confirm the split contract works end to end.
- Verify the API key. Use the demo shop to verify order creation, order queries and callback notifications.
3. Add more receipt addresses
- Once the above is confirmed, keep adding receipt addresses so more orders can be open at once.
- We recommend rounding up to a multiple of 50 (50, 100, 200…). As a rule of thumb, 50 is enough for low-frequency high-value payments; use 200 for high-frequency payments.
4. Go live
- With everything confirmed, deploy your integration to production.
Detailed walkthrough
Each of the four steps above has its own page. Read them in order:
- One-Key Setup — download the client, initialise the wallet, fill in and run one-key setup, save the account info
- Verify the Account — verify the split contract and the API key: block-explorer verification, test orders, aggregation and withdrawal
- Add More Receipt Addresses — batch-create receipt addresses up to 50 or more
- Go Live — update the API key parameters, configure the alert email