Skip to content

JenniferIze/escrownet-sdk

 
 

Repository files navigation

EscrowNet SDK

A TypeScript SDK for interacting with the EscrowNet smart contract on StarkNet.

Installation

npm install escrownet-sdk

Usage

import { EscrowNetSDK, Provider, Account } from 'escrownet-sdk';
import { RpcProvider } from 'starknet';

// Initialize the provider and account
const provider = new RpcProvider({ nodeUrl: 'YOUR_STARKNET_NODE_URL' });
const account = new Account(provider, 'YOUR_ACCOUNT_ADDRESS', 'YOUR_PRIVATE_KEY');

// Create SDK instance
const sdk = new EscrowNetSDK({
    provider,
    account
});

// Register a user
await sdk.registerUser('username');

// Create an escrow
const escrowId = await sdk.createEscrow({
    recipient: 'RECIPIENT_ADDRESS',
    amount: BigInt(1000000000000000000), // 1 ETH in wei
    description: 'Payment for services'
});

// Release funds
await sdk.releaseFunds(escrowId);

// Cancel escrow
await sdk.cancelEscrow(escrowId);

API Reference

EscrowNetSDK

The main class for interacting with the EscrowNet contract.

Constructor

constructor(config: EscrowNetSDKConfig)

Parameters:

  • config: Configuration object containing:
    • provider: StarkNet provider instance
    • account: StarkNet account instance

Methods

registerUser
async registerUser(username: string): Promise<void>

Registers a new user with the provided username.

Parameters:

  • username: The username to register
createEscrow
async createEscrow(params: EscrowParams): Promise<string>

Creates a new escrow contract.

Parameters:

  • params: Object containing:
    • recipient: The recipient's address
    • amount: The amount to escrow (in wei)
    • description: Description of the escrow

Returns:

  • Promise<string>: The escrow ID
releaseFunds
async releaseFunds(escrowId: string): Promise<void>

Releases funds to the recipient for a specific escrow.

Parameters:

  • escrowId: The ID of the escrow to release funds from
cancelEscrow
async cancelEscrow(escrowId: string): Promise<void>

Cancels an escrow contract.

Parameters:

  • escrowId: The ID of the escrow to cancel

Development

Building

npm run build

Testing

npm test

License

MIT

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 40.3%
  • TypeScript 22.3%
  • CSS 22.2%
  • HTML 15.2%