Skip to content

Eidolon-Labs/player-sdk-ts

Repository files navigation

@eidolon-labs/player-sdk

About the SDK

  • This is for Eidolon's Player API
  • The Player API is an invisible access layer for blockchain gaming
  • It is not designed or built for monetary purposes
  • It is designed to be used from a server

For examples of how to use the SDK, head over to https://github.com/Eidolon-Labs/player-api-examples

Installation

# NPM
npm add @eidolon-labs/player-sdk

# Yarn
yarn add @eidolon-labs/player-sdk

# PNPM
pnpm add @eidolon-labs/player-sdk

# Bun
bun add @eidolon-labs/player-sdk

Using the SDK

Setup

import { PlayerApi } from "@eidolon-labs/player-sdk";

const api = new PlayerApi({
    region: "us-east-2", // US East 2 is the default active region during Beta
    apiKey: "xxx-xxx-xxx"
});

Create Player

...

const player = await api.createPlayer({
    chainName: "nebula-testnet", // or nebula-mainnet
    suppliedId: "xxxx-xxxx-xxxx" // some id of yours in case you lose the Eidolon Id
});

console.log(player);
/*
{
    note: string;
    message: string;
    data: {
        accountId: string;
        player: {
            id: string;
            addresses: {
                evm: `0x${string}`;
            }
        }
    }
}
*/

Send Transaction

...

const tx = await playerApi.sendTransaction({
    chainName: "nebula-testnet",    // or nebula-mainnet
    playerId: "xxx-xxx-xxx",        // player id
    data: "0x...",                  // encoded function data for EVM
    to: "0x16378Cb38F5D153f63019C1Bd2297b585dE0f44C"
});

console.log(tx);
/*
{
    message: string;
    data: {
        transactionHash: string;
    }
}
*/

Encoding Function Data

Get Player

...
const player = await playerApi.getPlayer({
    playerId: "xxx-xxx-xxx"
});

console.log(player);
/*
{
    message: string;
    data: {
        player: {
            id: string;
            address: string;
            status: string;
        }
    }
}
*/

Notice

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Player SDK in Typescript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published