- Получение цены криптовалюты.
Вы можете получить цену криптовалюты с помощью различных API. Вот пример использования CoinGecko API в Python:
import requests
def get_crypto_price(coin):
url = f"https://api.coingecko.com/api/v3/simple/price?ids={coin}&vs_currencies=usd"
response = requests.get(url)
data = response.json()
price = data[coin]['usd']
return price
# Example usage
bitcoin_price = get_crypto_price('bitcoin')
print(f"The current price of Bitcoin is ${bitcoin_price}")
- Создание криптовалютного кошелька.
Вы можете создать криптовалютный кошелек, используя такие библиотеки, как web3.jsдля Ethereum. Вот пример на JavaScript:
const Web3 = require('web3');
const createWallet = async () => {
const web3 = new Web3();
const wallet = web3.eth.accounts.create();
console.log('Wallet Address:', wallet.address);
console.log('Private Key:', wallet.privateKey);
};
// Example usage
createWallet();
- Мониторинг криптовалютных транзакций.
Вы можете отслеживать криптовалютные транзакции с помощью обозревателей блокчейнов и API. Вот пример использования Etherscan API в Python:
import requests
def monitor_transactions(address):
url = f"https://api.etherscan.io/api?module=account&action=txlist&address={address}"
response = requests.get(url)
data = response.json()
transactions = data['result']
for tx in transactions:
print(f"Transaction Hash: {tx['hash']}")
print(f"From: {tx['from']}")
print(f"To: {tx['to']}")
print(f"Value: {tx['value']} wei")
print()
# Example usage
monitor_transactions('0x123456789abcdef123456789abcdef123456789a')
- График цен на криптовалюту.
Вы можете создавать графики цен на криптовалюты, используя такие библиотеки, как matplotlibв Python. Вот пример:
import matplotlib.pyplot as plt
def plot_price_chart(prices):
plt.plot(prices)
plt.xlabel('Time')
plt.ylabel('Price (USD)')
plt.title('Cryptocurrency Price Chart')
plt.show()
# Example usage with dummy data
prices = [100, 120, 150, 130, 140, 160]
plot_price_chart(prices)