# README
web3protocol-go
Parse and execute ERC-6860 / ERC-4804 web3://
protocol URLs.
Usage
import "github.com/web3-protocol/web3protocol-go"
config := web3protocol.Config{ ... } // Fill with the example in the configuration section
client := NewClient(&config)
fetchedWeb3Url, err := client.FetchUrl("web3://terraformnavigator.eth/view/1234")
fmt.Println("HTTP return code:", fetchedWeb3Url.HttpCode)
fmt.Printf("HTTP return headers: %+v\n", fetchedWeb3Url.HttpHeaders)
output, err := ioutil.ReadAll(fetchedWeb3Url.Output)
fmt.Println("Output bytes", output)
On top of the result, fetchedWeb3Url
contains a lot more details on the processing of the call.
Configuration
Right now, by default, this does not come with chains and domain name definitions; they will need to be provided. Here is an example for a basic Ethereum mainnet + ENS config, using the publicnode.com RPCs :
config := Config {
Chains: map[int]ChainConfig{
1: ChainConfig{
ChainId: 1,
ShortName: "eth",
RPC: "https://ethereum.publicnode.com/",
DomainNameServices: map[DomainNameService]DomainNameServiceChainConfig{
DomainNameServiceENS: DomainNameServiceChainConfig{
Id: DomainNameServiceENS,
ResolverAddress: common.HexToAddress("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"),
},
},
},
},
DomainNameServices: map[DomainNameService]DomainNameServiceConfig{
DomainNameServiceENS: DomainNameServiceConfig{
Id: DomainNameServiceENS,
Suffix: "eth",
DefaultChainId: 1,
},
},
}
Supported standards
Implemented features
- ERC-6860 (draft) : the base web3:// protocol with auto and manual mode, basic ENS support. This updates ERC-4804 (final) with clarifications, small fixes and changes.
- ERC-6821 (draft) : ENS resolution : support for the
contentcontract
TXT field to point to a contract in another chain - ERC-6944 (draft) / ERC-5219 (final) : New mode offloading some parsing processing on the browser side
- ERC-7617 (draft): Add chunk support in ERC-6944 resource request mode
- ERC-7618 (draft): Add Content-encoding handling in ERC-6944 resource request mode
Partially implemented features
- ERC-7087 (draft) : Auto mode : Add MIME type support (dataURLs not supported yet)
- ERC-7774 (pending): Cache invalidation in ERC-5219 mode Web3 URL (only ETag supported, wildcards not yet supported)
Testing
Web3:// test files are located in their own git repository and are imported as a git submodule. After cloning, please run git submodule init
and then git submodule update
.
Testing is then launched with go test
# Functions
Parse the Cache-Control header value into a map of directives.
Used for auto mode returning JSON : For a given ABI type and a value, convert it to a string, with the data formatted according to the spec.
LabelHash generates a simple hash for a piece of a name.
NameHash generates a hash from a name that can be used to look up the name in ENS.
*
* You'll need to instantiate a client to make calls.
No description provided by the author
Normalize normalizes a name according to the ENS rules.
No description provided by the author
Serialize the arguments of a resource request method, for the purpose of making a cache key.
# Constants
No description provided by the author
No description provided by the author
Expect the whole returned data to be ABI-encoded bytes.
Expect a string as first return value, parse it as a dataUrl ContractReturnProcessingDataUrl = "dataUrl" // To implement Expect a return following the erc5219 spec, will decode it using this spec.
JSON-encode the different return values.
JSON-encode the raw bytes of the returned data.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The config used by the client to make the web3:// calls.
Attributes of a domain name service specific to a chain.
Attributes of a domain name service.
An error type with a HTTP code.
This contains the result of a web3:// URL call : the parsed URL, the raw contract return, and the bytes output, HTTP code and headers for the browser.
A raw splitting of the web3 URL parts.
No description provided by the author
URL.parseQuery does not preserve the order of query attributes This is a version which keep order.
No description provided by the author
Caching infos for a specific resource.
Contains the caching infos of all the resources requested by the client that implements ERC-7774 (includes "evm-events" in the Cache-Control header).
Like ResourceRequestCachingTracker, but for a specific chain.
No description provided by the author
This contains a web3:// URL parsed and ready to call the main smartcontract.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author