Back

Google KMS

Google KMS

Overview

Following the sample Google KMS implementation:

1. Clone and configure the sample


_10
git clone https://github.com/openfort-xyz/samples
_10
cd external-kms-game

Copy the .env.example file into a file named .env in the folder of the server you want to use. For example:


_10
cp .env.example .env

You will need an Openfort account in order to run the demo. Once you set up your account, go to the Openfort developer dashboard to find your API keys.


_10
OPENFORT_SECRET_KEY=<replace-with-your-secret-key>
_10
OPENFORT_PUBLIC_KEY=<replace-with-your-publishable-key>

2. Create a Player, Policy and Contract

Required

You can create Policies and add Contracts in the Dashboard or with the API. This sample requires a Policy and a Contract to run. Once you've created them, and add its ID to your .env.

OPENFORT_PLAYER is the ID of a Player for your player.

OPENFORT_CONTRACT is the ID of a Contract for your contract. A contract has a chainId. If you need a test contract address, use 0x38090d1636069c0ff1Af6bc1737Fb996B7f63AC0 (NFT contract deployed in 80001 Mumbai).

OPENFORT_POLICY is the ID of a Policy for your contract. A policy has a contract and chainId. For this demo to work, the policy must have both the contract and the register sessions as rules.

3. Provide the KMS information In our example, we use Google Cloud Platform's KMS. In order to be able to use this sample, you will need to provide the details of the key to use:


_14
# Address of the PK stored in the Key of the KMS below
_14
EXTERNAL_OWNER_ADDRESS=
_14
_14
# KMS info
_14
# Your project id in GCP
_14
PROJECTID=
_14
# The location where your key ring was created
_14
LOCATIONID=
_14
# The id of the key ring
_14
KEYRINGID=
_14
# The name/id of your key in the key ring (the addres of this PK should be the EXTERNAL_OWNER_ADDRESS above)
_14
KEYID=
_14
# The version of the key
_14
KEYVERSION=

4. Follow the server instructions on how to run

Install & Run:


_10
npm install
_10
npm run dev
_10
# or
_10
yarn
_10
yarn dev

Details

DocumentationLearn

Get started with Google KMS and Openfort.