Initial
This commit is contained in:
commit
7281fc6955
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
build/
|
||||
vendor/
|
||||
keystore/
|
39
quiz/go.mod
Normal file
39
quiz/go.mod
Normal file
@ -0,0 +1,39 @@
|
||||
module quiz
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/ethereum/go-ethereum v1.13.1
|
||||
github.com/joho/godotenv v1.5.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.5.0 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||
github.com/consensys/bavard v0.1.13 // indirect
|
||||
github.com/consensys/gnark-crypto v0.10.0 // indirect
|
||||
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
|
||||
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.5 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/holiman/uint256 v1.2.3 // indirect
|
||||
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/supranational/blst v0.3.11 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
golang.org/x/crypto v0.12.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
|
||||
golang.org/x/mod v0.11.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/tools v0.9.1 // indirect
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
110
quiz/go.sum
Normal file
110
quiz/go.sum
Normal file
@ -0,0 +1,110 @@
|
||||
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
|
||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8=
|
||||
github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
|
||||
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y=
|
||||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
|
||||
github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 h1:T+Np/xtzIjYM/P5NAw0e2Rf1FGvzDau1h54MKvx8G7w=
|
||||
github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw=
|
||||
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM=
|
||||
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
|
||||
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/gnark-crypto v0.10.0 h1:zRh22SR7o4K35SoNqouS9J/TKHTyU2QWaj5ldehyXtA=
|
||||
github.com/consensys/gnark-crypto v0.10.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU=
|
||||
github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A=
|
||||
github.com/crate-crypto/go-kzg-4844 v0.3.0/go.mod h1:SBP7ikXEgDnUPONgm33HtuDZEDtWa3L4QtN1ocJSEQ4=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
|
||||
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg=
|
||||
github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
|
||||
github.com/ethereum/go-ethereum v1.13.1 h1:UF2FaUKPIy5jeZk3X06ait3y2Q4wI+vJ1l7+UARp+60=
|
||||
github.com/ethereum/go-ethereum v1.13.1/go.mod h1:xHQKzwkHSl0gnSjZK1mWa06XEdm9685AHqhRknOzqGQ=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
|
||||
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
|
||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
|
||||
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
|
||||
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
|
||||
github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o=
|
||||
github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw=
|
||||
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
|
||||
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
|
||||
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg=
|
||||
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y=
|
||||
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
|
||||
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
|
||||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
|
||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU=
|
||||
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
|
||||
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
|
||||
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
|
||||
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
|
38
quiz/main.go
Normal file
38
quiz/main.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var myenv map[string]string
|
||||
|
||||
const envLoc = ".env"
|
||||
|
||||
func loadEnv() {
|
||||
var err error
|
||||
if myenv, err = godotenv.Read(envLoc); err != nil {
|
||||
log.Printf("could not load env from %s: %v", envLoc, err)
|
||||
}
|
||||
}
|
||||
|
||||
func main(){
|
||||
loadEnv()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
client, err := ethclient.Dial(os.Getenv("GATEWAY"))
|
||||
if err != nil {
|
||||
log.Fatalf("could not connect to Ethereum gateway: %v\n", err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
accountAddress := common.HexToAddress("b56178e53bb7365db9c6a0afe9e9349e3f0db9a7")
|
||||
balance, _ := client.BalanceAt(ctx, accountAddress, nil)
|
||||
fmt.Printf("Balance: %d\n",balance)
|
||||
}
|
||||
|
286
quiz/quiz.go
Normal file
286
quiz/quiz.go
Normal file
@ -0,0 +1,286 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package quiz
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var (
|
||||
_ = errors.New
|
||||
_ = big.NewInt
|
||||
_ = strings.NewReader
|
||||
_ = ethereum.NotFound
|
||||
_ = bind.Bind
|
||||
_ = common.Big1
|
||||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
_ = abi.ConvertType
|
||||
)
|
||||
|
||||
// QuizMetaData contains all meta data concerning the Quiz contract.
|
||||
var QuizMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_qn\",\"type\":\"string\"},{\"internalType\":\"bytes32\",\"name\":\"_ans\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"checkBoard\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"question\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_ans\",\"type\":\"bytes32\"}],\"name\":\"sendAnswer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
|
||||
Bin: "0x608060405234801562000010575f80fd5b506040516200096f3803806200096f833981810160405281019062000036919062000213565b815f9081620000469190620004ae565b5080600181905550505062000592565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000b7826200006f565b810181811067ffffffffffffffff82111715620000d957620000d86200007f565b5b80604052505050565b5f620000ed62000056565b9050620000fb8282620000ac565b919050565b5f67ffffffffffffffff8211156200011d576200011c6200007f565b5b62000128826200006f565b9050602081019050919050565b5f5b838110156200015457808201518184015260208101905062000137565b5f8484015250505050565b5f620001756200016f8462000100565b620000e2565b9050828152602081018484840111156200019457620001936200006b565b5b620001a184828562000135565b509392505050565b5f82601f830112620001c057620001bf62000067565b5b8151620001d28482602086016200015f565b91505092915050565b5f819050919050565b620001ef81620001db565b8114620001fa575f80fd5b50565b5f815190506200020d81620001e4565b92915050565b5f80604083850312156200022c576200022b6200005f565b5b5f83015167ffffffffffffffff8111156200024c576200024b62000063565b5b6200025a85828601620001a9565b92505060206200026d85828601620001fd565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680620002c657607f821691505b602082108103620002dc57620002db62000281565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620003407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000303565b6200034c868362000303565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f62000396620003906200038a8462000364565b6200036d565b62000364565b9050919050565b5f819050919050565b620003b18362000376565b620003c9620003c0826200039d565b8484546200030f565b825550505050565b5f90565b620003df620003d1565b620003ec818484620003a6565b505050565b5b818110156200041357620004075f82620003d5565b600181019050620003f2565b5050565b601f82111562000462576200042c81620002e2565b6200043784620002f4565b8101602085101562000447578190505b6200045f6200045685620002f4565b830182620003f1565b50505b505050565b5f82821c905092915050565b5f620004845f198460080262000467565b1980831691505092915050565b5f6200049e838362000473565b9150826002028217905092915050565b620004b98262000277565b67ffffffffffffffff811115620004d557620004d46200007f565b5b620004e18254620002ae565b620004ee82828562000417565b5f60209050601f83116001811462000524575f84156200050f578287015190505b6200051b858262000491565b8655506200058a565b601f1984166200053486620002e2565b5f5b828110156200055d5784890151825560018201915060208501945060208101905062000536565b868310156200057d578489015162000579601f89168262000473565b8355505b6001600288020188555050505b505050505050565b6103cf80620005a05f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c806317d1653c146100435780633fad9ae01461007357806377f46bff14610091575b5f80fd5b61005d60048036038101906100589190610234565b6100af565b60405161006a9190610279565b60405180910390f35b61007b6100c4565b604051610088919061031c565b60405180910390f35b61009961014f565b6040516100a69190610279565b60405180910390f35b5f6100bd826001541461019f565b9050919050565b5f80546100d090610369565b80601f01602080910402602001604051908101604052809291908181526020018280546100fc90610369565b80156101475780601f1061011e57610100808354040283529160200191610147565b820191905f5260205f20905b81548152906001019060200180831161012a57829003601f168201915b505050505081565b5f60025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905090565b5f8160025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff02191690831515021790555060019050919050565b5f80fd5b5f819050919050565b61021381610201565b811461021d575f80fd5b50565b5f8135905061022e8161020a565b92915050565b5f60208284031215610249576102486101fd565b5b5f61025684828501610220565b91505092915050565b5f8115159050919050565b6102738161025f565b82525050565b5f60208201905061028c5f83018461026a565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156102c95780820151818401526020810190506102ae565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6102ee82610292565b6102f8818561029c565b93506103088185602086016102ac565b610311816102d4565b840191505092915050565b5f6020820190508181035f83015261033481846102e4565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061038057607f821691505b6020821081036103935761039261033c565b5b5091905056fea26469706673582212203b43da39773c8f47d07b68874cd450d17e39b1ce12855ac60675ae0ba9c90d8b64736f6c63430008150033",
|
||||
}
|
||||
|
||||
// QuizABI is the input ABI used to generate the binding from.
|
||||
// Deprecated: Use QuizMetaData.ABI instead.
|
||||
var QuizABI = QuizMetaData.ABI
|
||||
|
||||
// QuizBin is the compiled bytecode used for deploying new contracts.
|
||||
// Deprecated: Use QuizMetaData.Bin instead.
|
||||
var QuizBin = QuizMetaData.Bin
|
||||
|
||||
// DeployQuiz deploys a new Ethereum contract, binding an instance of Quiz to it.
|
||||
func DeployQuiz(auth *bind.TransactOpts, backend bind.ContractBackend, _qn string, _ans [32]byte) (common.Address, *types.Transaction, *Quiz, error) {
|
||||
parsed, err := QuizMetaData.GetAbi()
|
||||
if err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
if parsed == nil {
|
||||
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
|
||||
}
|
||||
|
||||
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(QuizBin), backend, _qn, _ans)
|
||||
if err != nil {
|
||||
return common.Address{}, nil, nil, err
|
||||
}
|
||||
return address, tx, &Quiz{QuizCaller: QuizCaller{contract: contract}, QuizTransactor: QuizTransactor{contract: contract}, QuizFilterer: QuizFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// Quiz is an auto generated Go binding around an Ethereum contract.
|
||||
type Quiz struct {
|
||||
QuizCaller // Read-only binding to the contract
|
||||
QuizTransactor // Write-only binding to the contract
|
||||
QuizFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// QuizCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type QuizCaller struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// QuizTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type QuizTransactor struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// QuizFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type QuizFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// QuizSession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type QuizSession struct {
|
||||
Contract *Quiz // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// QuizCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type QuizCallerSession struct {
|
||||
Contract *QuizCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
}
|
||||
|
||||
// QuizTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type QuizTransactorSession struct {
|
||||
Contract *QuizTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// QuizRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type QuizRaw struct {
|
||||
Contract *Quiz // Generic contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// QuizCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type QuizCallerRaw struct {
|
||||
Contract *QuizCaller // Generic read-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// QuizTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type QuizTransactorRaw struct {
|
||||
Contract *QuizTransactor // Generic write-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// NewQuiz creates a new instance of Quiz, bound to a specific deployed contract.
|
||||
func NewQuiz(address common.Address, backend bind.ContractBackend) (*Quiz, error) {
|
||||
contract, err := bindQuiz(address, backend, backend, backend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Quiz{QuizCaller: QuizCaller{contract: contract}, QuizTransactor: QuizTransactor{contract: contract}, QuizFilterer: QuizFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// NewQuizCaller creates a new read-only instance of Quiz, bound to a specific deployed contract.
|
||||
func NewQuizCaller(address common.Address, caller bind.ContractCaller) (*QuizCaller, error) {
|
||||
contract, err := bindQuiz(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &QuizCaller{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewQuizTransactor creates a new write-only instance of Quiz, bound to a specific deployed contract.
|
||||
func NewQuizTransactor(address common.Address, transactor bind.ContractTransactor) (*QuizTransactor, error) {
|
||||
contract, err := bindQuiz(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &QuizTransactor{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewQuizFilterer creates a new log filterer instance of Quiz, bound to a specific deployed contract.
|
||||
func NewQuizFilterer(address common.Address, filterer bind.ContractFilterer) (*QuizFilterer, error) {
|
||||
contract, err := bindQuiz(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &QuizFilterer{contract: contract}, nil
|
||||
}
|
||||
|
||||
// bindQuiz binds a generic wrapper to an already deployed contract.
|
||||
func bindQuiz(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := QuizMetaData.GetAbi()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_Quiz *QuizRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _Quiz.Contract.QuizCaller.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_Quiz *QuizRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.QuizTransactor.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_Quiz *QuizRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.QuizTransactor.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_Quiz *QuizCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _Quiz.Contract.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_Quiz *QuizTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_Quiz *QuizTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// CheckBoard is a free data retrieval call binding the contract method 0x77f46bff.
|
||||
//
|
||||
// Solidity: function checkBoard() view returns(bool)
|
||||
func (_Quiz *QuizCaller) CheckBoard(opts *bind.CallOpts) (bool, error) {
|
||||
var out []interface{}
|
||||
err := _Quiz.contract.Call(opts, &out, "checkBoard")
|
||||
|
||||
if err != nil {
|
||||
return *new(bool), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// CheckBoard is a free data retrieval call binding the contract method 0x77f46bff.
|
||||
//
|
||||
// Solidity: function checkBoard() view returns(bool)
|
||||
func (_Quiz *QuizSession) CheckBoard() (bool, error) {
|
||||
return _Quiz.Contract.CheckBoard(&_Quiz.CallOpts)
|
||||
}
|
||||
|
||||
// CheckBoard is a free data retrieval call binding the contract method 0x77f46bff.
|
||||
//
|
||||
// Solidity: function checkBoard() view returns(bool)
|
||||
func (_Quiz *QuizCallerSession) CheckBoard() (bool, error) {
|
||||
return _Quiz.Contract.CheckBoard(&_Quiz.CallOpts)
|
||||
}
|
||||
|
||||
// Question is a free data retrieval call binding the contract method 0x3fad9ae0.
|
||||
//
|
||||
// Solidity: function question() view returns(string)
|
||||
func (_Quiz *QuizCaller) Question(opts *bind.CallOpts) (string, error) {
|
||||
var out []interface{}
|
||||
err := _Quiz.contract.Call(opts, &out, "question")
|
||||
|
||||
if err != nil {
|
||||
return *new(string), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(string)).(*string)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// Question is a free data retrieval call binding the contract method 0x3fad9ae0.
|
||||
//
|
||||
// Solidity: function question() view returns(string)
|
||||
func (_Quiz *QuizSession) Question() (string, error) {
|
||||
return _Quiz.Contract.Question(&_Quiz.CallOpts)
|
||||
}
|
||||
|
||||
// Question is a free data retrieval call binding the contract method 0x3fad9ae0.
|
||||
//
|
||||
// Solidity: function question() view returns(string)
|
||||
func (_Quiz *QuizCallerSession) Question() (string, error) {
|
||||
return _Quiz.Contract.Question(&_Quiz.CallOpts)
|
||||
}
|
||||
|
||||
// SendAnswer is a paid mutator transaction binding the contract method 0x17d1653c.
|
||||
//
|
||||
// Solidity: function sendAnswer(bytes32 _ans) returns(bool)
|
||||
func (_Quiz *QuizTransactor) SendAnswer(opts *bind.TransactOpts, _ans [32]byte) (*types.Transaction, error) {
|
||||
return _Quiz.contract.Transact(opts, "sendAnswer", _ans)
|
||||
}
|
||||
|
||||
// SendAnswer is a paid mutator transaction binding the contract method 0x17d1653c.
|
||||
//
|
||||
// Solidity: function sendAnswer(bytes32 _ans) returns(bool)
|
||||
func (_Quiz *QuizSession) SendAnswer(_ans [32]byte) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.SendAnswer(&_Quiz.TransactOpts, _ans)
|
||||
}
|
||||
|
||||
// SendAnswer is a paid mutator transaction binding the contract method 0x17d1653c.
|
||||
//
|
||||
// Solidity: function sendAnswer(bytes32 _ans) returns(bool)
|
||||
func (_Quiz *QuizTransactorSession) SendAnswer(_ans [32]byte) (*types.Transaction, error) {
|
||||
return _Quiz.Contract.SendAnswer(&_Quiz.TransactOpts, _ans)
|
||||
}
|
26
quiz/quiz.sol
Normal file
26
quiz/quiz.sol
Normal file
@ -0,0 +1,26 @@
|
||||
pragma solidity >=0.5.2 <0.9.0;
|
||||
|
||||
contract Quiz {
|
||||
string public question;
|
||||
bytes32 internal _answer;
|
||||
mapping (address => bool) internal _leaderBoard;
|
||||
|
||||
constructor(string memory _qn, bytes32 _ans) {
|
||||
question = _qn;
|
||||
_answer = _ans;
|
||||
}
|
||||
|
||||
function sendAnswer(bytes32 _ans) public returns (bool){
|
||||
return _updateLeaderBoard(_answer == _ans);
|
||||
}
|
||||
|
||||
function _updateLeaderBoard(bool ok) internal returns (bool){
|
||||
_leaderBoard[msg.sender] = ok;
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkBoard() public view returns (bool){
|
||||
return _leaderBoard[msg.sender];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user