aboutsummaryrefslogtreecommitdiff
path: root/benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py')
-rw-r--r--benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py b/benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py
new file mode 100644
index 000000000..1d53c6565
--- /dev/null
+++ b/benchmark/agbenchmark/challenges/library/ethereum/check_price/artifacts_in/sample_code.py
@@ -0,0 +1,12 @@
+import requests
+
+
+def get_ethereum_price() -> float:
+ url = "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd"
+ response = requests.get(url)
+
+ if response.status_code == 200:
+ data = response.json()
+ return data["ethereum"]["usd"]
+ else:
+ raise Exception(f"Failed to fetch data: {response.status_code}")