Download the PHP package skopa/ethereum-rpc-wallet without Composer
On this page you can find all versions of the php package skopa/ethereum-rpc-wallet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ethereum-rpc-wallet
Ethereum JSONRPC Wallet
This package provide quick and simple interface to interact with your deployed contracts. For now realized full compatibility with ERC20 tokens. Also you can interact with any other your contract by using ABI code.
Not all responses are realized for now! Only static types: string, address, uint
THIS PACKAGE IS PROVIDE "AS IS"
Be careful that your case of using are fully tested!
Examples
Only few steps to start interact with your contract. Before this your contract must be successfully deployed on the blockchain network.
1.Create your contract class:
For creating and interacting with contract you need
to extend base class:
\Skopa\EthereumWallet\Contracts\ERC20TokenContract
And define next methods:
- getAddress() - must return address of your contract
- getABIJson() - must return json string of ABI code. Can be ignored for ERC20 contracts.
- getDecimals() - must return number of decimals
2.Connect to JSON RPC Geth server:
Setup the connection to your Geth server. How to do it you can find at https://github.com/ethereum/go-ethereum/wiki.
First parameter is server address with port. Second is chain id.
3. Create wallet instance:
Using public address:
If in future you will need to do signed actions you can just 'unlock' your wallet. If private key will from other wallet you will receive exception.
Using private key:
In this case wallet will unlocked from start.
4.Interact with contract:
To interact with you ERC20 contract just pass previously created
instance of ExampleContract
to wallet method as on example:
The $contractManager
is the instance of
\Skopa\EthereumWallet\ERC20ContractManager
that provide to you
methods of interactions:
- requestContractTokenData()
- balance()
- balanceOf(string $address)
- transfer(Transaction $transaction)
- approve(Transaction $transaction)
- allowance(string $spender)
- allowanceBy(string $owner, string $spender)
- transferFrom(Transaction $transaction)
Each method has documentation so you can investigate it by you-self.
4.1 Interaction with custom contract:
You also can use this lib to interact with your custom contacts.
You can create instance of your contract by extending class
of Skopa\EthereumWallet\Contracts\Contract
.
In this case you can create you own contract non compatible with
ERC20 and interact with it or event expand ERC20 contract with custom tokens.
But you will must provide ABI code.
Get contract manager and interact with it:
The Skopa\EthereumWallet\ContractManager
returned by customContract
method
has two methods to interact with contract:
- callDirectly(\Closure $closure) - call contract methods without sign
- callDirectlySigned(\Closure $closure) - call contract method by transaction
Of course you can extend ERC20 contract too:
And interact with it in same way:
5. Transaction:
To do some transactions you just need to create transaction instance
with recipient and amount. And send it by transfer
method of $contractManager
.
This method will the return transaction hash.
Reminder: Transaction are not immediate action (by blockchain spec).
6. Get transaction data:
You can get next data of transaction of your ERC20 contracts:
- from - sender address
- to - receiver address
- contract - address of contract
- timestamp - timestamp of block
- amount - amount of tokens
- success - boolean is transaction is success
To get this data you need call receipt
on wallet instance:
7. Additionally
Also lib contains some helpers like converters from decimal to hex and other. You can to get acquainted with it in source code.
Summary
This lib is not finished and can contain some bugs and exceptions. So it is distributed 'AS IS'.
To say thanks send some coins here: 0xfd9c54573dd27f23d3c8df154bd550df4c44bd8a
All versions of ethereum-rpc-wallet with dependencies
ext-json Version *
ext-mbstring Version *
web3p/ethereum-util Version ^0.1.1
web3p/ethereum-tx Version ^0.3.4
guzzlehttp/guzzle Version ^6.4
brick/math Version ^0.8.8