Usage examples

Below are some examples demonstrating how to make requests to each of the API methods described earlier.

1. Prepare a Transaction

These examples use the requests library, which is a popular choice for making HTTP requests in Python. If you haven't already, you will need to install the requests library using pip:

pip install requests
import requests
import json

url = "https://api.mama.io/v1/reforge/prepareReforge"
headers = {"Content-Type": "application/json"}
data = {
    "sourceAmount": "100",
    "sourceToken": "0x3c6af76181891a6f0f438d4d0fc1474f0e8ca9a0",
    "destinationToken": "0xc61e8563d354c4870d3526361d8531d79cd5dfe3",
    "destinationChainId": "0x61"
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

2. Execute a Transaction Asynchronously

url = "https://api.mama.io/v1/reforge/executeReforgeAsync"
data = {
    "tx": "prepared_transaction_data",
    "walletData": {
        "rpcUrl": "https://sourcechain.rpc.url",
        "privateKey": "your_wallet_private_key"
    }
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

3. Execute a Transaction

url = "https://api.mama.io/v1/reforge/executeReforge"
data = {
    "tx": "prepared_transaction_data",
    "walletData": {
        "rpcUrl": "https://sourcechain.rpc.url",
        "privateKey": "your_wallet_private_key"
    }
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

4. Get Supported Chains and Tokens

url = "https://api.mama.io/v1/reforge/getChainsAndTokens"

response = requests.get(url)
print(response.text)

These examples show how to use different languages to interact with the API, including how to send GET and POST requests, how to include headers, and how to serialize to JSON for the request body. Remember to adjust parameters as needed to match your requirements.