Download the PHP package sleefinance/simple-web3-php without Composer
On this page you can find all versions of the php package sleefinance/simple-web3-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sleefinance/simple-web3-php
More information about sleefinance/simple-web3-php
Files in sleefinance/simple-web3-php
Informations about the package simple-web3-php
simple-web3-php
A php interface for interacting with the Ethereum blockchain and ecosystem.
Features
- PHP >= 7.4
- Customizable curl calls
- Call: get net state
- Send signed transactions
- Batch call requests and signed transactions
- Address & private key creation
- Message signing
- Full ABIv2 encode/decode
- Contract creation
- Contract interaction (call/send)
- Contract Events/logs with filters
- Support for ERC20 contracts with non-nominative decimal values
- Examples provided interacting with simple types, strings, tuples, arrays, arrays of tuples with arrays, multi-dimension arrays...
Install
Latest stable release
Or you can add this line in composer.json
Development (main branch)
Or you can add this line in composer.json
Usage
New instance
Convert values
- Most calls return hex or BigNumber to represent numbers.
- Most calls expect numeric parameters represented as BigNumbers.
Hex to Big Number:
Number to BigNumber:
Get average-human readable string representation from Big Number:
Format 1 ether to wei (unit required for ether values in transactions):
Get average-human readable string representation from a value conversion:
General ethereum block information call:
Refresh gas price
Estimate gas price (from send params)
Send 0.001 ether to address
Batch calls & transactions
Account
Contract interaction
Contract events (logs)
Contract creation (deployment)
Usual required includes
Provided Examples
In the folder Examples/ there are some extended examples with call & send examples:
- example.call.php
- example.send.php
- example.batch.php
- example.account.php
- example.contract_creation.php
-
example.erc20.php
Example configuration
To execute the examples you will need to add some data to the configuration file (example.config.php).
The example is pre-configured to work with an infura endpoint:
Just add your infura project keys. If you have not configured the api secret key requisite, just ignore it.
If you are using a private endpoint, just ignore all the infura definitions:
To enable contract interaction, set the contract data (address & ABI). The file is preconfigured to work with our example contract, already deployed on ropsten.
To enable transaction sending & signing, enter a valid pair of address and private key. Please take this advises before continuing:
- The address must be active on the ropsten network and have some ether available to send the transactions.
- Double check that you are using a test endpoint, otherwise you will be spending real eth to send the transactions
- Be sure to keep your private key secret!
Example contract
The solidity contract used in this example is available too in the same folder: swp_contract.sol
Example disclaimer
Don't base your code structure on this example. This example does not represent clean / efficient / performant aproach to implement them in a production environment. It's only aim is to show some of the features of Simple Web3 Php.
Modules
- Utils library forked & extended from web3p/web3.php
- Transaction signing: kornrunner/ethereum-offline-raw-tx
- sha3 encoding: from kornrunner/keccak
- BigNumber interaction: phpseclib\Math
- Asymetric key handling: simplito/elliptic-php
TODO
- Node accounts creation / interaction
License
MIT
DONATIONS (ETH)
All versions of simple-web3-php with dependencies
kornrunner/ethereum-offline-raw-tx Version ^0.6.0
kornrunner/keccak Version ~1
phpseclib/phpseclib Version ~2.0.30
simplito/elliptic-php Version ^1.0