All Projects → web3-php → web3

web3-php / web3

Licence: MIT License
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to web3

Eth Crypto
Cryptographic javascript-functions for ethereum and tutorials to use them with web3js and solidity
Stars: ✭ 420 (-31.03%)
Mutual labels:  dapp, web3, eth
Web3swift
Elegant Web3js functionality in Swift. Native ABI parsing and smart contract interactions.
Stars: ✭ 237 (-61.08%)
Mutual labels:  dapp, json-rpc, web3
vue-web3
🐙 Web3 blockchain bindings for Vue.js (inspired by Vuefire and Drizzle)
Stars: ✭ 63 (-89.66%)
Mutual labels:  dapp, web3, eth
laravel-web3
Laravel SDK wrapper for the Web3 PHP API client that interacts with the Ethereum blockchain.
Stars: ✭ 85 (-86.04%)
Mutual labels:  web3, eth
cyberevents
The protocol for EVENTs and TICKETs
Stars: ✭ 16 (-97.37%)
Mutual labels:  dapp, web3
MultiDexArbBot
This is an arbitrage bot that uses existing price aggregators such as 1inch, Paraswap, dex.ag, matcha and more to get the best exchange rates across different decentralized exchanges on different blockchains and ecosystems.
Stars: ✭ 67 (-89%)
Mutual labels:  dapp, web3
foundry
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Stars: ✭ 4,623 (+659.11%)
Mutual labels:  dapp, eth
web3-webpacked
Drop-in web3 solution for single-page Ethereum dApps
Stars: ✭ 36 (-94.09%)
Mutual labels:  dapp, web3
eth-commerce
Javascript library to accept ethereum payments on any website
Stars: ✭ 24 (-96.06%)
Mutual labels:  dapp, web3
web3-starter
An opinionated web3 starter for building dApps
Stars: ✭ 67 (-89%)
Mutual labels:  dapp, web3
moesif-ethereum-js-example
An example of a Dapp built on web3js/ethereum and using Moesif to monitor JSON-RPC calls.
Stars: ✭ 37 (-93.92%)
Mutual labels:  dapp, json-rpc
openzeppelin-network.js
An easy to use and reliable library that provides one line access to Web3 API.
Stars: ✭ 45 (-92.61%)
Mutual labels:  dapp, web3
ton-client-js
Everscale Javascript SDK
Stars: ✭ 60 (-90.15%)
Mutual labels:  dapp, web3
typescript-eth-starter
🔌 Ethereum Dapp Basic Typescript Starter
Stars: ✭ 125 (-79.47%)
Mutual labels:  dapp, web3
framework
Lightweight, open source and magic-free framework for testing solidity smart contracts.
Stars: ✭ 36 (-94.09%)
Mutual labels:  web3, eth
nft-app
How to create your own NFT and mint NFT token
Stars: ✭ 145 (-76.19%)
Mutual labels:  dapp, web3
juice-interface
🧃 An app for using the JBX protocol.
Stars: ✭ 132 (-78.33%)
Mutual labels:  dapp, web3
eth-sdk
Type-safe, lightweight SDKs for Ethereum smart contracts
Stars: ✭ 283 (-53.53%)
Mutual labels:  dapp, web3
Astar
The dApp hub for blockchains of the future
Stars: ✭ 533 (-12.48%)
Mutual labels:  dapp, web3
kleros-api-DEPRECATED
A Javascript library that makes it easy to build relayers and other DApps that use the Kleros protocol. DEPRECATED use https://github.com/kleros/archon for interfacing with standard arbitration contracts.
Stars: ✭ 20 (-96.72%)
Mutual labels:  dapp, web3

Web3 PHP

GitHub Workflow Status (master) Total Downloads Latest Version License


Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

This project is a work-in-progress. Code and documentation are currently under development and are subject to change.

Get Started

Requires PHP 8.0+

First, install Web3 via the Composer package manager:

composer require web3-php/web3 dev-master

Then, interact with a local (web3-php/cli) or remote ethereum node:

use Web3\Web3;

$web3 = new Web3('http://127.0.0.1:8545');

$accounts = $web3->eth()->accounts(); // ['0x54a3259f4f693e4c1e9daa54eb116a0701edc403', ...]

Usage

Web3 Namespace

clientVersion

The clientVersion method returns the version of the current client.

$web3->clientVersion(); // TestRPC v2.13.2

sha3

The sha3 method hashes data using the Keccak-256 algorithm.

$web3->sha3('string'); // 0x348ab0847d053bb0150c1eb3470a71071d2967e20cf131b59dea3df9bf8f753e

Eth Namespace

accounts

The accounts method returns a list of addresses owned by this client.

$web3->eth()->accounts(); // ['0x54a3259f4f693e4c1e9daa54eb116a0701edc403', ...]

chainId

The chainId method returns the current chain id.

$web3->eth()->chainId(); // 1

gasPrice

The gasPrice method returns the current price of gas in wei.

$web3->eth()->gasPrice()->toEth(); // 0.00000002

getBalance

The getBalance method returns the balance of an address in wei.

$web3->eth()->getBalance('0x54a3259f4f693e4c1e9daa54eb116a0701edc403')->toEth(); // 100

getBlockTransactionCountByHash

The getBlockTransactionCountByHash method returns the number of transactions in a block by its hash.

$web3->eth()->getBlockTransactionCountByHash('0xd2a91777651a08b92d1d9fc701982c79da2249532cfe41a773a340978f96b5d1'); // 266

getTransactionByHash

The getTransactionByHash method returns information about a transaction by its hash.

$web3->eth()->getTransactionByHash('0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b');

getTransactionReceipt

The getTransactionReceipt method returns the receipt for a transaction by its hash.

$web3->eth()->getTransactionReceipt('0xbb3a336e3f823ec18197f1e13ee875700f08f03e2cab75f0d0b118dabb44cba0');

getUncleCountByBlockHash

The getUncleCountByBlockHash method returns the number of uncles in a block by its hash.

$web3->eth()->getUncleCountByBlockHash('0xd2a91777651a08b92d1d9fc701982c79da2249532cfe41a773a340978f96b5d1'); // 266

hashrate

The hashrate() method returns the number of hashes-per-second this node is mining at.

$web3->eth()->hashrate(); // '65' 

isMining

The isMining() method determines if the client is mining new blocks.

$web3->eth()->isMining(); // true 

blockNumber

The blockNumber() method returns the number (quantity) of the most recent block seen by this client.

$web3->eth()->blockNumber(); // '3220' 

coinbase

The coinbase() method returns the Coinbase address of the client.

$web3->eth()->coinbase(); // '0xc014ba5ec014ba5ec014ba5ec014ba5ec014ba5e' 

sendTransaction

The sendTransaction method creates, signs, and sends a new transaction to the network.

use Web3\ValueObjects\{Transaction, Wei};

$from = '0xc9257b94da7f8eb07537db73a4ad0603cd83aba4';
$to = '0x108d1089e4a737c0be63527a6e464564be948b03';
$value = Wei::fromEth('1');

$transaction = Transaction::between($from, $to)->withValue($value);

$web3->eth()->sendTransaction($transaction); // '0xa124a7de5177cf5cedd3c44e91d115d0011f915905fa36fb7c000a491fa536ee' 

submitWork

The submitWork() method submits a proof-of-work solution, and returns a boolean based on the result.

$web3->eth()->submitWork($nonce, $proofOfWorkHash, $mixDigest); // true 

Net Namespace

listening

The listening method determines if this client is listening for new network connections.

$web3->net()->listening(); // true

peerCount

The peerCount method returns the number of peers currently connected to this client.

$web3->net()->peerCount(); // 230

version

The version method returns the chain ID associated with the current network.

$web3->net()->version(); // 1637712995212

Web3 PHP is an open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].