Skip to main content

WaaS Authentication

WaaS is authenticated with API keys. This page explains how to create an API key and test its validity with the WaaS Client Libraries.

Prerequisites

This guide assumes that you:

info

Admins and Owners can create up to ten API key pairs.

Test API Key

WaaS client libraries let you access the WaaS APIs. They include a script that lets you test your API key and ensure you are authorized to hit the WaaS API endpoints.

info

Currently, we only support Golang client libraries.

Client Libraries

  1. Navigate into the repo waas-client-library-go:

    cd {path_to}/waas-client-library-go
  2. Edit in example.go by replacing the variables with your API Key information, for example:

    a. Analyze your keypair which looks like this, with the actual values replaced by {variableNames}.

    {
    "name": "organizations/{organizationID}/apiKeys/{apiKeyId}",
    "principal": "{principalID}",
    "principalType": "USER",
    "publicKey": "-----BEGIN EC PUBLIC KEY-----\n{PUBLIC_KEY}\n-----END EC PUBLIC KEY-----\n",
    "privateKey": "-----BEGIN EC PRIVATE KEY-----\n{PRIVATE_KEY}\n-----END EC PRIVATE KEY-----\n",
    "createTime": "2023-03-21T02:02:45.362863508Z"
    }

    b. Look for this section in example.go:

    const (
    // apiKeyName is the name of the API Key to use. Fill this out before running the main function.
    apiKeyName = "organizations/my-organization/apiKeys/my-api-key"

    // apiKeyPrivateKey is the private key of the API Key to use. Fill this out before running the main function.
    apiKeyPrivateKey = "-----BEGIN EC PRIVATE KEY-----\nmy-private-key\n-----END EC PRIVATE KEY-----\n"
    )

    c. Replace and save:

    • my-organization with the value of your organizationID
    • my-api-key with the value of your apiKeyId
    • my-private-key with the value of your PRIVATE_KEY between the \n bookends.
  3. Run the following commands:

    go build
    ./waas-client-library-go

    If the client to server connection is working, and your key is valid, you should see output like the following:

    2023/03/20 20:11:29 creating pool...
    2023/03/20 20:11:29 created pool: name:"pools/a80d2ede-b745-496d-85cc-f1e4784dbf99" display_name:"My First Pool"
    2023/03/20 20:11:29 listing networks...
    2023/03/20 20:11:30 got network: name:"networks/ethereum-goerli" display_name:"Goerli Ethereum Testnet" native_asset:"networks/ethereum-goerli/assets/0c3569d3-b253-5128-a229-543e1e819430" protocol_family:"protocolFamilies/evm" type:TESTNET
    2023/03/20 20:11:30 listing first 5 assets on Ethereum Goerli...
    2023/03/20 20:11:30 got asset: name:"networks/ethereum-goerli/assets/0c3569d3-b253-5128-a229-543e1e819430" advertised_symbol:"ETH" decimals:18 definition:{asset_type:"native"}
    2023/03/20 20:11:30 got asset: name:"networks/ethereum-goerli/assets/adbf9e76-de39-51a0-9e53-5f8ef31b7925" advertised_symbol:"POLY" decimals:18 definition:{asset_type:"erc20" asset_group_id:"0x887CFe31C888EE0780795b7feFF46CE7f9AB556C"}
    2023/03/20 20:11:30 got asset: name:"networks/ethereum-goerli/assets/a055a425-fe93-51ae-9099-cf5495db6e79" advertised_symbol:"SIM" decimals:18 definition:{asset_type:"erc20" asset_group_id:"0x0E89BF4135acE3d4d67BF828707746D3855f3a25"}
    2023/03/20 20:11:30 got asset: name:"networks/ethereum-goerli/assets/145f3157-a45d-5a77-92be-6b2af8b7af12" advertised_symbol:"TERC20" decimals:18 definition:{asset_type:"erc20" asset_group_id:"0xea100Bec80418680e55D28b655da6CbEF427275f"}
    2023/03/20 20:11:30 got asset: name:"networks/ethereum-goerli/assets/20b2830e-53c1-5540-9d1b-0061df3555f6" advertised_symbol:"BETH" decimals:18 definition:{asset_type:"erc20" asset_group_id:"0xED6CCd7e5131073aE67221B1cA195db0fFacc940"}

Was this helpful?