https://github.com/dongri/go-ether
https://github.com/dongri/go-ether
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dongri/go-ether
- Owner: dongri
- Created: 2023-03-17T00:41:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T09:28:28.000Z (almost 2 years ago)
- Last Synced: 2025-01-21T05:15:48.451Z (3 months ago)
- Language: Go
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Ether
## Test Wallet
https://github.com/dongri/web3/tree/master/ethereum-wallet-generator```
mnemonic : daughter mimic all potato spare scheme term claim acid segment either ritualprivate key 0: 0xcc9c0c2a98e539a19cfb44f674b4a1fb1f07e0072184cbdcd0524136542ea060
address 0: 0x0c9B5d5C6f4f095DA9Db0685689b6a22b0bF17C6
```## Usage
```go
import (
goether "github.com/dongri/go-ether"
)
goether.PersonalSign("message", "privateKey")
```## SignKeccak256Message
```go
privateKey := "cc9c0c2a98e539a19cfb44f674b4a1fb1f07e0072184cbdcd0524136542ea060"
message := "hello world"
address := "0x1cE28c56C1Eb78C2d8c0059f37f6BF2B21484616"
value := "1000000000000000000"
types := []string{"string", "address", "uint256"}
args := []string{message, address, value}
signature, err := goether.SignKeccak256Message(types, args, privateKey)
```Like Web3.js
```javascript
const sha3message = web3.utils.soliditySha3("hello world", "0x1cE28c56C1Eb78C2d8c0059f37f6BF2B21484616", "1000000000000000000")
const signature = await web3.eth.accounts.sign(sha3message, privateKey)
```Verify Solidity
```solidity
function _verify(bytes32 __data, bytes memory __signature, address __account) internal pure returns (bool) {
return __data
.toEthSignedMessageHash()
.recover(__signature) == __account;
}
```## PersonalSign
Like Web3.js
```javascript
const message = "helloworld"
const signature = await web3.eth.personal.sign(message, account)
```## VerifyPersonalSign
Like Web3.js
```javascript
const message = "helloworld"
const recovered = await web3.eth.personal.ecRecover(message, signature)
```