Skip to content

Commit

Permalink
Updating v0.0.6 README
Browse files Browse the repository at this point in the history
  • Loading branch information
erdimaden committed May 31, 2024
1 parent 1b29d3a commit ea9d426
Showing 1 changed file with 54 additions and 18 deletions.
72 changes: 54 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,63 @@ Currently, the SDK is intended for use on testnet for quick bootstrapping of cry

## Installation

### In Your Node.js Project
### Requirements

The Coinbase server-side SDK requires Node.js version 18 or higher and npm version 9.7.2 or higher. To view your currently installed versions of Node.js, run the following from the command-line:

```bash
npm install @coinbase/coinbase-sdk
node -v
npm -v
```

or
We recommend installing and managing Node.js and npm versions with `nvm`. See [Installing and Updating](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) in the `nvm` README for instructions on how to install `nvm`.

Once `nvm` has been installed, you can install and use the latest versions of Node.js and npm by running the following commands:

```bash
yarn install @coinbase/coinbase-sdk
nvm install node # "node" is an alias for the latest version
nvm use node
```

### In the ts-node REPL
### In Your Project

After running `npx ts-node` to start the REPL, you can import the SDK as follows:
Optional: Initialize the npm

```typescript
import { Coinbase } from "@coinbase/coinbase-sdk";
This command initializes a new npm project with default settings and configures it to use ES modules by setting the type field to "module" in the package.json file.

```bash
npm init -y; npm pkg set type="module"
```

### Requirements
### Install the SDK
```bash
npm install @coinbase/coinbase-sdk
```

or

- Node.js 18 or higher
```bash
yarn install @coinbase/coinbase-sdk
```

## Usage

### Initialization

#### You can import the SDK as follows:

CommonJs:

```javascript
const { Coinbase } = require("@coinbase/coinbase-sdk");
```

ES modules:

```typescript
import { Coinbase } from "@coinbase/coinbase-sdk";
```

To start, [create a CDP API Key](https://portal.cdp.coinbase.com/access/api). Then, initialize the Platform SDK by passing your API Key name and API Key's private key via the `Coinbase` constructor:

```typescript
Expand All @@ -63,8 +92,23 @@ const coinbase = Coinbase.configureFromJson("path/to/your/api-key.json");

This will allow you to authenticate with the Platform APIs and get access to the default `User`.

CommonJs:

```javascript
const { Coinbase } = require("@coinbase/coinbase-sdk");
const coinbase = Coinbase.configureFromJson("path/to/your/api-key.json");
coinbase.getDefaultUser().then(user => {
console.log(user);
});
```

Or using ES modules and async/await:

```typescript
import { Coinbase } from "@coinbase/coinbase-sdk";
const coinbase = Coinbase.configureFromJson("path/to/your/api-key.json");
const user = await coinbase.getDefaultUser();
console.log(user);
```

### Wallets, Addresses, and Transfers
Expand Down Expand Up @@ -193,14 +237,6 @@ To run a specific test, run (for example):
npx jest ./src/coinbase/tests/wallet_test.ts
```

### REPL

The repository is equipped with a REPL to allow developers to play with the SDK. To start it, run:

```bash
npx ts-node
```

### Generating Documentation

To generate documentation from the TypeDoc comments, run:
Expand Down

0 comments on commit ea9d426

Please sign in to comment.