dynamicedge API
  • Welcome Dynamic EDGE
  • DYNAMIC PRODUCT SUITE
    • Dynamic Protocol Mcp
    • MCP Protocol: STDIO vs SSE
    • Developer Toolkit Suite
    • DEVELOPER GUIDE
    • use-case
    • Web3 Integration Guide
    • ecosystem
    • ROADMAP
Powered by GitBook
On this page
Export as PDF
  1. DYNAMIC PRODUCT SUITE

Web3 Integration Guide

Dynamic Web3 Integration Guide

Introduction

Dynamic edge is designed to bridge the gap between advanced artificial intelligence and decentralized technologies in the Web3 ecosystem. This guide provides a comprehensive overview of how to integrate Dynamic with blockchain networks, deploy smart contracts, and utilize wallet authentication to power AI-driven decentralized applications.

Integration Architecture

Dynamic integrates with various blockchain networks using a modular and secure approach. Key components include:

  • Blockchain Connectors: Modular components that connect to blockchain nodes (e.g., Ethereum, Binance Smart Chain).

  • Wallet Authentication: Mechanisms to verify user identities via decentralized wallet signatures.

  • Smart Contract Interfaces: APIs for deploying, interacting with, and monitoring smart contracts on the blockchain.

  • Data Synchronization: Real-time tracking of on-chain events and transactions to update agent states.

  • Wallet Compatibility: Full support for major Solana wallets including Phantom, Solflare, and Backpack, providing users with familiar and secure ways to manage their DET tokens and interact with the Dynamic Edge platform.

  • DeFi Integration: DET tokens are integrated into Solana's decentralized finance ecosystem. This includes establishing and supporting DET liquidity pools on major Solana DEXs like Raydium and Orca, enabling efficient trading. Furthermore, exploring opportunities for DET to be used as collateral for decentralized lending protocols such as MarginFi allows holders to leverage their assets within the ecosystem.

Connecting to Blockchain Networks

Dynamic provides pre-configured blockchain connectors that allow for seamless communication with decentralized networks. These connectors can be customized based on the target blockchain's parameters. For example, connecting to Ethereum can be achieved by configuring the provider URL and network ID.

Example: Ethereum Connection

Below is a sample code snippet demonstrating how to connect DeepCore to the Ethereum network using a connector module:

from dynamic.tools import BlockchainConnector
​
# Initialize a blockchain connector for Ethereum
eth_connector = BlockchainConnector(
    provider_url='https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID',
    network_id=1
)
​
# Test connection by fetching the latest block number
latest_block = eth_connector.get_latest_block()
print(f'Latest Ethereum Block: {latest_block}')

Smart Contract Integration

Dynamic agents can interact with smart contracts to execute transactions, trigger events, and automate decentralized workflows. The platform provides a Smart Contract Executor tool that abstracts the complexities of contract interactions.

Deploying and Interacting with a Smart Contract

Below is an example of deploying a simple smart contract and invoking its functions:

from dynamic.tools import SmartContractExecutor
​
# Define the smart contract's ABI and bytecode
contract_abi = [
    {
        "constant": False,
        "inputs": [{"name": "_value", "type": "uint256"}],
        "name": "setValue",
        "outputs": [],
        "type": "function"
    },
    {
        "constant": True,
        "inputs": [],
        "name": "getValue",
        "outputs": [{"name": "", "type": "uint256"}],
        "type": "function"
    }
]
contract_bytecode = "0x608060405234801561001057600080fd5b50610107806100206000396000f3fe6080604052600436106100295760003560e01c8063"  
​
# Initialize a smart contract executor
contract_executor = SmartContractExecutor(
    connector=eth_connector,
    abi=contract_abi
)
​
# Deploy the smart contract
contract_address = contract_executor.deploy(bytecode=contract_bytecode, deploy_args=[123])
print(f'Deployed Contract Address: {contract_address}')
​
# Call a contract function
tx_hash = contract_executor.call_function(
    contract_address,
    function_name='setValue',
    args=[456]
)
print(f'Transaction Hash: {tx_hash}')

Wallet Authentication in Web3

Dynamic leverages wallet-based authentication to ensure secure and decentralized access. Users sign a nonce sent by the platform, and the signature is verified to authenticate access without compromising private keys.

Wallet Authentication Workflow

  1. Request a Nonce: The client requests a unique nonce from DeepCore.

  2. Sign the Nonce: The user signs the nonce using their blockchain wallet.

  3. Verify Signature: The signature is sent back to DeepCore for verification, granting access upon success.

Previoususe-caseNextecosystem

Last updated 12 days ago