contracts

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 2 Imported by: 4

README

SingularityNET Ecosystem Contracts Package

The package was created to easily work with SingularityNET ecosystem EVM contracts

Python

Usage

Easily get an instance of the contract you need from any SingularityNET product with just one call to one of the functions

Install:

pip install snet.contracts

Usage:

from snet.contracts import get_contract_deployment_block, get_contract_object

import web3

provider = web3.HTTPProvider("https://mainnet.infura.io/v3/")
w3 = web3.Web3(provider)

token_contract_instance = get_contract_object(w3, "SingularityNetToken")
deployed_block = get_contract_deployment_block(w3, "SingularityNetToken")
print("Block:", deployed_block)

Result:

Block: 12326815

Optional: get an instance at the contract address

token_contract_instance = get_contract_object(w3, "SingularityNetToken" "0x5B7533812759B45C2B44C19e320ba2cD2681b542")
Tests
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 test/unit_test.py

Golang

Install
go get -u github.com/singnet/snet-ecosystem-contracts
Usage
package main

import (
	"fmt"
	"github.com/singnet/snet-ecosystem-contracts"
)

func main() {

	// get list of all contracts
	fmt.Println(contracts.List)
	
	// get ABI of contract Registry
	fmt.Println(string(contracts.GetABI(contracts.Registry)))

	// get bytecode of contract SingularityNetToken
	fmt.Println(string(contracts.GetBytecode(contracts.SingularityNetToken)))

	// get addresses, events, and more for smart contracts for different networks
	fmt.Println(string(contracts.GetNetworks(contracts.Registry)))

	// clean methods returns content without spaces and line breaks
	fmt.Println(string(contracts.GetABIClean(contracts.SingularityNetToken)))
	fmt.Println(string(contracts.GetBytecodeClean(contracts.Registry)))
	fmt.Println(string(contracts.GetNetworksClean(contracts.SingularityNetToken)))
}

Documentation

Overview

Package contracts provide golang functions to read smart-contracts of snet-ecosystem

Index

Constants

This section is empty.

Variables

Functions

func GetABI

func GetABI(name SnetContract) (content []byte)

func GetABIClean

func GetABIClean(name SnetContract) (content []byte)

GetABIClean returns content without spaces and line breaks

func GetBytecode

func GetBytecode(name SnetContract) (content []byte)

func GetBytecodeClean

func GetBytecodeClean(name SnetContract) (content []byte)

GetBytecodeClean returns content without double quotes, spaces and line breaks

func GetNetworks

func GetNetworks(name SnetContract) (content []byte)

get addresses, events, and more for smart contracts for different networks

func GetNetworksClean

func GetNetworksClean(name SnetContract) (content []byte)

GetNetworksClean returns networks without spaces and line breaks

Types

type SnetContract

type SnetContract string
const MultiPartyEscrow SnetContract = "MultiPartyEscrow"
const Registry SnetContract = "Registry"
const SingularityNetToken SnetContract = "SingularityNetToken"
const TokenConversionManager SnetContract = "TokenConversionManager"
const TokenStake SnetContract = "TokenStake"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL