Skip to content

Commit e8e6a83

Browse files
authored
Fixing the example - new one (#16)
1 parent 69ebcb1 commit e8e6a83

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

examples/get_contract_by_chain_id_and_address.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/ethereum/go-ethereum/common"
66
"github.com/unpackdev/sourcify-go"
7+
"github.com/davecgh/go-spew/spew"
78
"net/http"
89
"time"
910
)
@@ -26,19 +27,10 @@ func Example_GetContractByChainIdAndAddress() {
2627
)
2728

2829
// Get source code for the Binance Smart Chain with the address of the R3T contract
29-
sources, err := sourcify.GetContractSourceCode(client, 56, common.HexToAddress("0x054B2223509D430269a31De4AE2f335890be5C8F"), sourcify.MethodMatchTypeAny)
30+
sources, err := sourcify.GetContractByChainIdAndAddress(client, 56, common.HexToAddress("0x054B2223509D430269a31De4AE2f335890be5C8F"), []string{"all"}, []string{})
3031
if err != nil {
3132
panic(err)
3233
}
3334

34-
// Print the status of the source code retrieval
35-
fmt.Printf("Status: %+v\n", sources.Status)
36-
37-
// Iterate over the source code files and print their names and paths
38-
for _, source := range sources.Code {
39-
fmt.Printf("Name: %+v\n", source.Name)
40-
fmt.Printf("Path: %+v\n", source.Path)
41-
// Uncomment the following line to print the content of the source code
42-
//fmt.Printf("Content: %+v\n\n", source.Content)
43-
}
35+
spew.Dump(sources)
4436
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module github.com/unpackdev/sourcify-go
33
go 1.24.3
44

55
require (
6+
github.com/davecgh/go-spew v1.1.1
67
github.com/ethereum/go-ethereum v1.15.11
78
github.com/goccy/go-json v0.10.4
89
github.com/google/uuid v1.3.0
910
github.com/stretchr/testify v1.10.0
1011
)
1112

1213
require (
13-
github.com/davecgh/go-spew v1.1.1 // indirect
1414
github.com/holiman/uint256 v1.3.2 // indirect
1515
github.com/pmezard/go-difflib v1.0.0 // indirect
1616
golang.org/x/crypto v0.38.0 // indirect

0 commit comments

Comments
 (0)