Created
April 8, 2022 19:39
-
-
Save KenoLeon/a20b1a68e969f5934a69516a799a1f96 to your computer and use it in GitHub Desktop.
example of promise in the MetaMask API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| params: [ | |
| { | |
| from: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', | |
| to: '0xd46e8dd67c5d32be8058bb8eb970870f07244567', | |
| gas: '0x76c0', // 30400 | |
| gasPrice: '0x9184e72a000', // 10000000000000 | |
| value: '0x9184e72a', // 2441406250 | |
| data: | |
| '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', | |
| }, | |
| ]; | |
| ethereum | |
| .request({ | |
| method: 'eth_sendTransaction', | |
| params, | |
| }) | |
| .then((result) => { | |
| // The result varies by RPC method. | |
| // For example, this method will return a transaction hash hexadecimal string on success. | |
| }) | |
| .catch((error) => { | |
| // If the request fails, the Promise will reject with an error. | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment