Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ferranbt/heura
DSL to interact with Ethereum smart contracts
https://github.com/ferranbt/heura
blockchain dsl ethereum
Last synced: 10 days ago
JSON representation
DSL to interact with Ethereum smart contracts
- Host: GitHub
- URL: https://github.com/ferranbt/heura
- Owner: ferranbt
- License: apache-2.0
- Created: 2018-11-05T10:58:38.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2023-02-25T00:48:55.000Z (over 1 year ago)
- Last Synced: 2023-07-12T05:11:47.509Z (over 1 year ago)
- Topics: blockchain, dsl, ethereum
- Language: Go
- Homepage:
- Size: 109 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Heura
Ethereum DSL to interact with smart contracts, call and listen for events.
## Install
```
go get github.com/umbracle/heura/heura
```## Usage
Start the REPL:
```
go run main.go
```Run a specific file:
```
go run main.go source.hra
```By default, Heura uses the Infura mainnet nodes to make calls to contracts (https) and listen for events (websockets). Those values can be modified by setting the next flags:
```
go run main.go --endpoint --wsendpoint
```## Syntax
Heura is an interpreted language. It is still a work in progress and the syntax is expected to change.
### Artifacts
Load artifacts from folder or files
```
artifact (
"./abis",
"./artifacts/0x.json"
)
```or use the builtin ones:
```
artifacts (
"ERC20"
)
```### Calls
Once the artifact is loaded, you can instantiate contracts at specific addresses:
```
let token = ERC20(0x...)
```or use ENS:
```
let token = ERC20("sometoken.eth")
```After this, the call functions specified in the ABI are available:
```
token.decimals();
```Transactions are not supported.
### Events
Listen for ethereum events:
```
on ERC20.Transfer (from, to, value) {
print (from)
}
```or filter for an specific address (with either the address or an ENS name):
```
on ERC20("somename.eth").Transfer (from, to, value)
```Inside the scope of the event callback there is a special 'this' variable with information about the transaction that executed the event: blocknumber, blockhash, transaction hash and an instance of the contract that emit the event.
```
on ERC20.Transfer (from, to, value) {
print (this.blocknumber)
print (this.obj.symbol())
}
```It is possible to filter by specific topic values in the event:
```
let FROM=0xB9536d30A25466a909563EE4f35fE3c158fc2964on ERC20.Transfer(from=FROM, to, value) {
```Note that is only possible with parameters that are indexed on the event.
### Functions
Functions are declared with the keyword 'fn' and can return multiple values.
```
fn some_function() {
return 1, 2
}let x, y := some_function()
```### Libraries
### Etherscan
Query a specific contract on Etherscan:
```
import "etherscan"print(ens.Contract("0x..."))
```Fetch ABIs from Etherscan:
```
import "etherscan"let Contract = ens.Contract("0x")
on Contract.Transfer(from, to, value) {
}
```### Ens
Resolve an ENS address:
```
import "ens"print(ens.Resolve("address.eth"))
```