Code Monkey home page Code Monkey logo

web3.fs's Introduction

web3.fs

A library offering a more functional interface to Ethereum/EVM RPCs.

Progress

Release 0.3.0 is available. This is a semi-mature release covering most functionality from an RPC library.

Deps and Reqs

FSharp.Data
FSharp.Json
SHA3Core
FsHttp

Writen in .Net 6

Example Use

// Build local nuget package and reference
open Web3.fs

// create a web3 environment, a record which contains an RPC endpoint, transaction monitor
// and logger.
let env = createWeb3Environment "http://127.0.0.1" "2.0" "0x426F..."

// If you log frequently, make a partial application
let logIt = env.log Log

// load your contract ABI and bytecode
let abi, bytecode = returnABIAndBytecodeFromSolcJsonFile "./MyContract.json"

//Deploy and load in one step. GANACHE is a constant for the chainId, set to 0x539
// Our contract takes one constructor argument, and isn't payable.
let contract = 
    prepareDeployAndLoadContract bytecode abi GANACHE [Address "0xccfe00b..."] ZEROVALUE env
    |> optimisticallyBindDeployedContract
  
// call a function on your contract
contractCall contract (ByName "estimateYield") [] env |> logIt

// [+] Success
// Call result: 1500364000000

// make a transaction (deposit ETH)
contractTransaction contract Receieve [] ((Ether "1") |> asWei) env |> logIt

// [@] Monitoring transaction 0x03b804ffaff877f9ea492ab878c13471a3f98c95fe7de9161464f52fba752064
// [+] Success
// <transaction data>

// oops, our contract has an overloaded function. 
contractTransaction contract (ByName "withdraw") [] ZEROVALUE env |> logIt
// [!] AmbiguousFunctionError

// We want this one
contractTransaction contract (ByNameAndMutability ("withdraw", Nonpayable)) [] ZEROVALUE env |> logIt
// [@] Monitoring transaction 0x0738a45aaff817f9ebb92ab8786f5371a3f98c95fe7de9161464f52fbaee54c0
// [+] Success
// <transaction data>

Code of Conduct

I'm a dictator and I rule with an iron fist. I explicitly reject CoCs.

web3.fs's People

Contributors

jmhickman avatar

Stargazers

jinczing avatar Ben Collins avatar

Watchers

 avatar

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.