Coder Social home page Coder Social logo

masa-sdk's Introduction

Installation

yarn
yarn add @masa-finance/masa-sdk --save

npm
npm i @masa-finance/masa-sdk --save

Usage

Browser:

import { Masa } from "@masa-finance/masa-sdk";
import { providers } from "ethers";

// with metamask
const provider = new providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

// by default Masa SDK will assume the provider points to ethereum mainnet and
// will load contracts accordingly. If you plan to connect to a different network
// the networkName must be specified i.e. like this: networkName: "goerli"

export const masa = new Masa({
  signer,
  // networkName: "goerli",
});

Node:

import { Masa } from "@masa-finance/masa-sdk";
import { providers, Wallet } from "ethers";

const provider = new providers.JsonRpcProvider("your blockchain rpc endpoint");
const wallet = new Wallet("your private key", provider);

// by default Masa SDK will assume the provider points to ethereum mainnet and
// will load contracts accordingly. If you plan to connect to a different network
// the networkName must be specified i.e. like this: networkName: "goerli"

export const masa = new Masa({
  signer: wallet,
  // networkName: "goerli",
});

Interface

For a detailed interface description see Masa

Configuration

Key Type Description Default Value
cookie string Cookie value. Don't set this manually unless you know what you do!
wallet ethers.Signer or ethers.Wallet The Wallet instance to use when interacting with the Blockchain. "wallet with a random private key"
apiUrl string The API Endpoint of the Masa Infrastructure for dev, test, beta and production. "https://dev.middleware.masa.finance/"
environment string The environment to use dev, test, beta, production. "dev"
network string The network name ie. "goerli". "goerli"
arweave.host string The arweave host to use for loading metadata. "arweave.net"
arweave.port number The arweave port to use for loading metadata. 443
arweave.protocol string The arweave protocol to use for loading metadata. "https"
arweave.logging boolean Turn arweave logging on or off. false
new Masa({
  // cookie value for connecting with the backend
  cookie: "my fancy cookie",
  // wallet object is always mandatory
  wallet,
  // api endpoint to the masa infrastructure
  apiUrl: "https://middleware.masa.finance",
  // masa environment dev, test, beta, prod
  environment: "prod",
  // network name to use goerli, mainnet
  network: "goerli",
  // arweave endpoint to use
  arweave: {
    host: "arweave.net",
    port: 443,
    protocol: "https",
    logging: false,
  },
});

masa-sdk's People

Contributors

dependabot[bot] avatar h34d avatar hide-on-bush-x avatar im-khem avatar juanmanso avatar nolanjacobson avatar obasilakis avatar teslashibe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

masa-sdk's Issues

Spike: Research Solana JavaScript SDK integration in Masa SDK

We are planning to deploy contracts to solana. To be able to use them we have to attest the changes that are required to add the solana SDK to the masa sdk and make it connect to solana.

Acceptance Criteria

  • Add Solana SDK to Masa SDK
  • Connect to solana testnet/devnet
  • Transact on solana testnet/devnet

Output

Smart Contracts

There is no concept called smart contracts at Solana. Instead they follow a concept that is called Program. There is a default program called splToken which is very similar to ERC20 tokens on EVM and comes with its own factory. Based on the findings with the OFT implementation on Solana we might or might not use that Program for the Masa Token. To ship functionality like staking we need a custom staking program. There is no known code generation framework like we are using with ABIs and ethers.js so we might up ending keeping the using code and in the SDK and the contract itself in sync manually.

Wallets

My implementation of Solana here is based on a connection / keypair construct similar to the wallet construct from ethers.js. Since we are not exactly sure what a wallet connection in the browser would deliver we can go ahead with the keypair solution for now. It works very well in the cli. It enables us to use public keys as addresses. I used it to transact to send SOL from one to another wallet. All of the wallets are derived from a seedphrase in the cli right now. We must make sure we can properly inject the provider once we have solved this in masa-react.

Networks

I added two of three solana networks to the networks collection that are flagged as "non evm" so we must ignore them when ever we do something evm related. In the cli the network switching worked like on all the other evm networks. I am not sure how a web provider like phantom would react on a network switch.

Utils

The tooling supplied by the solana web3 sdk itself is basic. I was able to send around SOL and do balance calculation based on that but i have not seen any tooling to access custom programs.

Add SoulBoundGreen to Base Mainnet

import { base as baseAddresses } from "@masa-finance/masa-contracts-identity/addresses.json";

import type { Addresses } from "../../interface";

const {
  SoulboundIdentity: SoulboundIdentityAddress,
  SoulName: SoulNameAddress,
  SoulStore: SoulStoreAddress,
} = baseAddresses;

export const base: Addresses = {
  SoulboundIdentityAddress,
  SoulNameAddress,
  SoulStoreAddress,
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.