Sign with Due Vault

Once you've created a transfer and intent (see Stablecoin to Fiat Transfers guide), you'll need to sign the transaction hashes.

Note: This process uses Pattern 2: Challenge-Response Flow - similar to vault creation.

Request Signing Challenge

For each signable hash in your intent:

curl --location 'https://api.due.network/v1/vaults/sign' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
    "payload": {
        "keyId": "key_2lRmxX5KBYRzMg",
        "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
    }
}'

Note: keyId is the Due Vault ID returned when you created the vault (not the credential ID).

Challenge Response

You'll receive a 403 error with a challenge:

{
    "success": false,
    "message": "Please sign the following challenge to proceed",
    "httpCode": 403,
    "code": "ACTION_SIGNATURE_REQUIRED",
    "data": {
        "factors": {
            "Key": {
                "credId": "",
                "clientData": "eyJ0eXBlIjoia2V5LmdldCIsImNoYWxsZW5nZSI6ImNoYWxsZW5nZTFET0NNcDNFWWk4VFlZWU9ka25sOEJHZlZ3SzZQRkNwbSIsIm9yaWdpbiI6Imh0dHBzOi8vYXBwLnNhbmRib3guZHVlLm5ldHdvcmsiLCJjcm9zc09yaWdpbiI6ZmFsc2V9",
                "signature": null
            }
        },
        "challengeIdentifier": "chid1DLr5F2ij7oyYLrGy6ekLnouxbE5SiiaN"
    }
}

Sign the Challenge

echo -n "<clientData_from_response>" | base64 -d | openssl dgst -sha256 -sign private.pem | base64 -w 0 | tr '+/' '-_' | tr -d '='

Get Transaction Signature

Submit the signed challenge with the same payload:

curl --location 'https://api.due.network/v1/vaults/sign' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
    "payload": {
        "keyId": "key_2lRmxX5KBYRzMg",
        "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
    },
    "signature": {
        "challengeIdentifier": "chid1DLr5F2ij7oyYLrGy6ekLnouxbE5SiiaN",
        "firstFactor": {
            "kind": "Key",
            "credentialAssertion": {
                "credId": "passkey_xonETR6gAv3wIyhy8ehjx",
                "clientData": "<original_clientData>",
                "signature": "<your_signature>"
            }
        }
    }
}'

Response:

{
    "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
    "signature": "0xd37f997e3850ad3e2eff15f62ecaa06932671c069327987223d76ec63feadaa315af671042155724f4212c345abbee5a766d0984ad4c3848d1838df6fb4519691b"
}

Submit the Intent

Use the signature(s) to submit your transfer intent:

Important:

  • In submit, you need to send the intent returned from the transfer_intent endpoint with signatures added to its signables.
  • Each signable should have a separate signature.
  • The signature should contain the transaction signature (from the response), not the challenge signatures.
curl -X POST https://api.due.network/v1/transfer_intents/submit \
-H "Authorization: Bearer your_api_key" \
-H "Due-Account-Id: your_account_id" \
-H "Content-Type: application/json" \
-d '{
  "token": "intent_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "id": "{intent_id}",
  "sender": "0x742d35Cc6665C0532925a3b8D98d0dfBb67B1BF8",
  "amountIn": "1000000000",
  "to": {
    "0x1234567890123456789012345678901234567890": "1000000000"
  },
  "tokenIn": "USDC",
  "tokenOut": "USDC", 
  "networkIdIn": "ethereum",
  "networkIdOut": "ethereum",
  "gasFee": "21000000000000000",
  "signables": [
    {
      "signature": "0xd37f997e3850ad3e2eff15f62ecaa06932671c069327987223d76ec63feadaa315af671042155724f4212c345abbee5a766d0984ad4c3848d1838df6fb4519691b",
      "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
      "type": "EIP712",
      "data": {
        "types": {
          "Transfer": [
            {"name": "to", "type": "address"},
            {"name": "amount", "type": "uint256"},
            {"name": "nonce", "type": "uint256"}
          ]
        },
        "domain": {
          "name": "DueProtocol",
          "version": "1",
          "chainId": 1
        },
        "message": {
          "to": "0x1234567890123456789012345678901234567890",
          "amount": "1000000000",
          "nonce": "123"
        }
      }
    }
  ],
  "nonce": "0x7b",
  "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
  "reference": "{transfer_id}_deposit",
  "expiresAt": "2024-03-15T10:40:15Z",
  "createdAt": "2024-03-15T10:30:45Z"
}'