forked from web3p/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexampleBase.php
113 lines (102 loc) · 2.8 KB
/
exampleBase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
$dir = dirname(__FILE__);
require($dir . '/vendor/autoload.php');
use Web3\Web3;
$web3 = new Web3('https://bsc-dataseed.binance.org/');
$eth = $web3->eth;
// BSC chain id, remember to set the right chain id
// Find chain id here: https://chainlist.org/
$chainId = 56;
/**
* erc20Json
* Openzeppelin abi from https://github.com/OpenZeppelin/openzeppelin-contracts
*/
$erc20JsonFile = file_get_contents($dir . '/ERC20.json');
$erc20Json = json_decode($erc20JsonFile);
/**
* erc721Json
* Openzeppelin abi from https://github.com/OpenZeppelin/openzeppelin-contracts
*/
$erc721JsonFile = file_get_contents($dir . '/ERC721.json');
$erc721Json = json_decode($erc721JsonFile);
/**
* testPrivateKey
* Never use this in real world
*
* @var string
*/
$testPrivateKey = '';
/**
* testAddress
* Never use this in real world
*
* @var string
*/
$testAddress = '';
/**
* testAddress2
* Never use this in real world
*
* @var string
*/
$testAddress2 = '';
/**
* settings for testing uniswap based DEX
*
* $testUNIAbi
* uniswap router abi
*
* @var string
*
* $testUNIRouterAddress
* uniswap router address
*
* @var string
*/
$testUNIAbi = '[
{
"inputs":[
{"internalType":"uint256","name":"amountOutMin","type":"uint256"},
{"internalType":"address[]","name":"path","type":"address[]"},
{"internalType":"address","name":"to","type":"address"},
{"internalType":"uint256","name":"deadline","type":"uint256"}
],
"name":"swapExactETHForTokens",
"outputs":[
{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}
],
"stateMutability":"payable",
"type":"function"
},
{
"inputs":[
{"internalType":"uint256","name":"amountIn","type":"uint256"},
{"internalType":"uint256","name":"amountOutMin","type":"uint256"},
{"internalType":"address[]","name":"path","type":"address[]"},
{"internalType":"address","name":"to","type":"address"},
{"internalType":"uint256","name":"deadline","type":"uint256"}
],
"name":"swapExactTokensForTokens",
"outputs":[
{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}
],
"stateMutability":"nonpayable",
"type":"function"
},
{
"inputs":[
{"internalType":"uint256","name":"amountIn","type":"uint256"},
{"internalType":"uint256","name":"amountOutMin","type":"uint256"},
{"internalType":"address[]","name":"path","type":"address[]"},
{"internalType":"address","name":"to","type":"address"},
{"internalType":"uint256","name":"deadline","type":"uint256"}
],
"name":"swapExactTokensForETH",
"outputs":[
{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}
],
"stateMutability":"nonpayable",
"type":"function"
}
]';
$testUNIRouterAddress = '0x10ed43c718714eb63d5aa57b78b54704e256024e';