11.4. Sending documents with blockchain support

In the previous examples we created envelopes with blockchain supported documents. In this example we will use our stored blockchain keys we got in creating new companies section and send the envelope.

Please open BlockChain Add Files and send folder in Postman Integration Examples. Creating Envelope, adding files and sealing envelope are same as in creating new companies section. The only difference is document_type - now is MBL, which has full blockchain support. Everything is set in examples, so you just click through it.

Tip

We don't describe specific calls and responses here - it's easy to see them right in Postman. On every request call you can see what call is being made, what headers, body and parameters we send and what response we fetch. Also check Tests tab - there we check the response and parse some data from it.

11.4.1. Sign hash with blockchain key and send envelope

In this example we will use external service and metamask for signing message with blockchain key. When implementing integration programmatically check the API and examples sections for more help.

First, install metamask, follow instructions here: https://metamask.io/. Then, import test company blockchain key: https://metamask.zendesk.com/hc/en-us/articles/360015489331-How-to-import-an-Account

As said, we will use external service for signing message: https://www.myetherwallet.com/. Connect to https://www.myetherwallet.com/wallet/access with newly imported wallet (select "Browser Extension") and head to https://www.myetherwallet.com/wallet/sign/ section. Copy-paste hash from previous request and sign it with metamask. The end result should be like this:

../_images/blockchain3.png

We will need sig data - that is actual signed hash. In the next request - sending documents via blockchain to our contact, we copy-paste entire response from Create Envelopes with documents request and add signed hash from mycrypto.com as signature field to it. This we add into JSON:

{"action":"issue","data": "RESPONSE FROM GENERATE ISSUE HASH + SIGNED HASH}

Entire Request body for this example (data will be different when you send it):

{"action":"issue","data":
      [
          {
              "document_token_id": "2ec589b8-9637-45f3-b940-09f376fe4bd0",
              "relayed_transaction": {
                  "hash": "0xe314477182e70b34581dbd0fc8073ff98eb58260c35e1532dd4a41230fe43079",
                  "relay_nonce": 1,
                  "recipient": "0xc8e04f362dB54e3FFeE14fC173f231B1A09DE851",
                  "relayed_for": "0xaA1116C4ce9f195D9730EF4CF803cA5d2bcAD868",
                  "signature": "b8412d807ac8532d4e6733e8be3a9795e33ba3065b2425725380be1c74347d91538a8b61c907af8ce20af31951e4e811222162f962670d890387edcb9e80a4ac1c",
                  "transaction_data": "0x3266df5b00000000000000000000000065902b6f61181650a9c5488d580c420acf6a9463000000000000000000000000000000002ec589b8963745f3b94009f376fe4bd06a08172c4205ea4fa51fb7b4fea6ed4d3789eb986d3bf1213094c8e110cfec9300000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ef8fa3588f2574c1665dabd27a8b029e1e52c4e00000000000000000000000000000000000000000000000000000000000000001"
              }
          }
      ]
   }

When we send the request we can see that we get a 200 OK response:

../_images/envelope6.png

We can also see that envelope with blockchain document was delivered to test company2

../_images/blockchain5.png