native(to, amount)
Transfers the native token from the signer to a target address.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| to | str | Required | Required | The recipient address (either SS58 or EVM H160). |
| amount | int | float | str | Decimal | Required | Required | Human-readable token amount (e.g., 1.5). |
Native Token Transfer Code Examples
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")
EVM_ADDRESS = os.getenv("EVM_ADDRESS")
sdk = Sdk.create_instance(
base_url=HTTPS_PEAQ_URL,
chain_type=ChainType.EVM,
seed=EVM_PRIVATE_KEY
)
amount = 1.5
response = sdk.transfer.native(to=EVM_ADDRESS, amount=amount)
{
"message": "Sent 1.5 native-token from 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C to 0x3e3FF16083Bf0a444B8fF86C7156eB3368e3cefB.",
"receipt": {
"transactionHash": "0xeb349f98c31e414b76a674ed7b435005e9e717bc6459156d736c66999bec5728",
"transactionIndex": 0,
"blockHash": "0xa28e6d76a5b2aea0c24c9f4e39c548c1ddcaeebcffdf6273a4e07b3db36730c0",
"from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
"to": "0x3e3FF16083Bf0a444B8fF86C7156eB3368e3cefB",
"blockNumber": 5848490,
"cumulativeGasUsed": 21000,
"gasUsed": 21000,
"contractAddress": null,
"logs": [],
"logsBloom": "0x000000000000000000000000000000000000000000000...",
"status": 1,
"effectiveGasPrice": 102000000000,
"type": 2
}
}
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")
SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")
sdk = Sdk.create_instance(
base_url=HTTPS_PEAQ_URL,
chain_type=ChainType.EVM,
seed=EVM_PRIVATE_KEY
)
amount = 1.5
response = sdk.transfer.native(to=SUBSTRATE_ADDRESS, amount=amount)
{
"message": "Sent 1.5 native-token from 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C to 5FEw7aWmqcnWDaMcwjKyGtJMjQfqYGxXmDWKVfcpnEPmUM7q.",
"receipt": {
"transactionHash": "0x006077a3dbc93d2ebaa3ed20e4764ba41de122edd2eaa338f4e593750dcd6d6f",
"transactionIndex": 0,
"blockHash": "0xb64e5c258440264ff9f354700a56e96102fddedfcabd937f20081ad40843965e",
"from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
"to": "0x0000000000000000000000000000000000000809",
"blockNumber": 5848515,
"cumulativeGasUsed": 30423,
"gasUsed": 30423,
"contractAddress": null,
"logs": [
{
"address": "0x0000000000000000000000000000000000000809",
"topics": [
"0xa1f949b36d49ecc12f7df90e9e1c2dfc2091941dbc70b29ad1b995253a47853b",
"0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c",
"0x8c81c81b633fae0cc5713dd9d7ac2ae9fe5d63112b396554c0d8e19b199daf1d"
],
"data": "0x00000000000000000000000000000000000000000000000014d1120d7b160000",
"blockHash": "0xb64e5c258440264ff9f354700a56e96102fddedfcabd937f20081ad40843965e",
"blockNumber": 5848515,
"transactionHash": "0x006077a3dbc93d2ebaa3ed20e4764ba41de122edd2eaa338f4e593750dcd6d6f",
"transactionIndex": 0,
"logIndex": 0,
"transactionLogIndex": "0x0",
"removed": false
}
],
"logsBloom": "0x000000000000000000000000080000000080000...",
"status": 1,
"effectiveGasPrice": 102000000000,
"type": 2
}
}
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")
EVM_ADDRESS = os.getenv("EVM_ADDRESS")
sdk = Sdk.create_instance(
base_url=WSS_PEAQ_URL,
chain_type=ChainType.SUBSTRATE,
seed=SUBSTRATE_SEED
)
amount = 1.5
response = sdk.transfer.native(to=EVM_ADDRESS, amount=amount)
{
"message": "Sent 1.5 native-token from 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg to 0x3e3FF16083Bf0a444B8fF86C7156eB3368e3cefB.",
"receipt": {
"extrinsic_hash": "0x18097b6e184090630d0a136c477a37b80460b8cf9e79074289e2e00b20549e07",
"block_hash": "0x8616cb83c69ff2795b4cea5eab7cd3ed5dcd3c634f6dbdc3f373ecff9a96e8fc",
"from": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
"to": "5Gt6N8WZRfWDuULHrQyVd1qbcHiuVjMTq5MyKhDss7s2mCUF",
"amount": 1500000000000000000,
"fee": 1972642001704138,
"events": [
...
{
"event": "Transfer",
"from": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
"to": "5Gt6N8WZRfWDuULHrQyVd1qbcHiuVjMTq5MyKhDss7s2mCUF",
"amount": 1500000000000000000
},
...
],
"success": true
}
}
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
WSS_PEAQ_URL = os.getenv("WSS_PEAQ_URL")
SUBSTRATE_SEED = os.getenv("SUBSTRATE_SEED")
SUBSTRATE_ADDRESS = os.getenv("SUBSTRATE_ADDRESS")
sdk = Sdk.create_instance(
base_url=WSS_PEAQ_URL,
chain_type=ChainType.SUBSTRATE,
seed=SUBSTRATE_SEED
)
amount = 1.5
response = sdk.transfer.native(to=SUBSTRATE_ADDRESS, amount=amount)
{
"message": "Sent 1.5 native-token from 5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg to 5FEw7aWmqcnWDaMcwjKyGtJMjQfqYGxXmDWKVfcpnEPmUM7q.",
"receipt": {
"extrinsic_hash": "0xbe07335455ba0dfb33812499a42e8b9c16df65932281ed162696559c5de73494",
"block_hash": "0x4a015f85f4a858f89977c981b0b165af0cfa110534a6f89a041843ab6946733d",
"from": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
"to": "5FEw7aWmqcnWDaMcwjKyGtJMjQfqYGxXmDWKVfcpnEPmUM7q",
"amount": 1500000000000000000,
"fee": 1972642001704138,
"events": [
...
{
"event": "Transfer",
"from": "5Df42mkztLtkksgQuLy4YV6hmhzdjYvDknoxHv1QBkaY12Pg",
"to": "5FEw7aWmqcnWDaMcwjKyGtJMjQfqYGxXmDWKVfcpnEPmUM7q",
"amount": 1500000000000000000
},
...
],
"success": true
}
}
erc20(erc_20_address, recipient_address, amount, token_decimals)
Transfers ERC-20 tokens from the signer to a recipient address.| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| erc_20_address | str | Required | N/A | The address of the ERC-20 contract. |
| recipient_address | str | Required | N/A | The recipient’s address. |
| amount | int | float | str | Decimal | Required | N/A | Human-readable token amount. |
| token_decimals | int | float | str | Decimal | Optional | N/A | Number of decimals for the token (defaults to 18). |
ERC-20 Transfer Code Examples
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")
sdk = Sdk.create_instance(
base_url=HTTPS_PEAQ_URL,
chain_type=ChainType.EVM,
seed=EVM_PRIVATE_KEY
)
ERC_20_ADDRESS = os.getenv("ERC_20_ADDRESS")
EVM_ADDRESS = os.getenv("EVM_ADDRESS")
amount = 1.5
token_decimals = 18
response = sdk.transfer.erc20(
erc_20_address=ERC_20_ADDRESS,
recipient_address=EVM_ADDRESS,
amount=amount,
token_decimals=token_decimals
)
{
"message": "Transferred 1.5 of the erc-20 at address 0xFF78784737e8e124cb38603eD3DA78f071f50c2a to the new owner of 0x3e3FF16083Bf0a444B8fF86C7156eB3368e3cefB from the owner 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C.",
"receipt": {
"transactionHash": "0xc1b8bd9a02a59bcd21aa71200c0e4c7c38117636262cdeae462bd029e24538fc",
"transactionIndex": 0,
"blockHash": "0xef507bcb8f5fb76fb28d24573597d86618d0d5e4965f3d352bd48fd21c2178ce",
"from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
"to": "0xFF78784737e8e124cb38603eD3DA78f071f50c2a",
"blockNumber": 5848651,
"cumulativeGasUsed": 34492,
"gasUsed": 34492,
"status": 1,
"effectiveGasPrice": 102000000000,
"type": 2,
"logs": [
{
"address": "0xFF78784737e8e124cb38603eD3DA78f071f50c2a",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c",
"0x0000000000000000000000003e3ff16083bf0a444b8ff86c7156eb3368e3cefb"
],
"data": "0x00000000000000000000000000000000000000000000000014d1120d7b160000",
"blockHash": "0xef507bcb8f5fb76fb28d24573597d86618d0d5e4965f3d352bd48fd21c2178ce",
"blockNumber": 5848651,
"transactionHash": "0xc1b8bd9a02a59bcd21aa71200c0e4c7c38117636262cdeae462bd029e24538fc",
"transactionIndex": 0,
"logIndex": 0,
"transactionLogIndex": "0x0",
"removed": false
}
]
}
}
erc721(erc_721_address, recipient_address, token_id)
Transfers an ERC-721 token (NFT) from the signer to a recipient address using thesafeTransferFrom method.
| Parameter | Type | EVM | Substrate | Description |
|---|---|---|---|---|
| erc_721_address | str | Required | N/A | The address of the ERC-721 contract. |
| recipient_address | str | Required | N/A | The recipient’s address. |
| token_id | int | Required | N/A | The ID of the token to transfer. |
ERC-721 Transfer Code Examples
import os
from dotenv import load_dotenv
from peaq_sdk import Sdk
from peaq_sdk.types import ChainType
load_dotenv()
HTTPS_PEAQ_URL = os.getenv("HTTPS_PEAQ_URL")
EVM_PRIVATE_KEY = os.getenv("EVM_PRIVATE_KEY")
sdk = Sdk.create_instance(
base_url=HTTPS_PEAQ_URL,
chain_type=ChainType.EVM,
seed=EVM_PRIVATE_KEY
)
ERC_721_ADDRESS = os.getenv("ERC_721_ADDRESS")
EVM_ADDRESS = os.getenv("EVM_ADDRESS")
TOKEN_ID = 1
response = sdk.transfer.erc721(
erc_721_address=ERC_721_ADDRESS,
recipient_address=EVM_ADDRESS,
token_id=TOKEN_ID
)
{
"message": "Transferred NFT at address 0x3319176b32a4c1e68c02ef454c148ee9b5363c33 to the new owner of 0x3e3FF16083Bf0a444B8fF86C7156eB3368e3cefB from the owner 0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C.",
"receipt": {
"transactionHash": "0xd483ec3f28326c27d824b2d42fc434ee16c2f25a900d87c4a6a3dd383e87547d",
"transactionIndex": 0,
"blockHash": "0xb71f47ee73a11a8653397bb7e3ea9e40d8bbdc5a2382db72aae854027f5e62c3",
"from": "0x9Eeab1aCcb1A701aEfAB00F3b8a275a39646641C",
"to": "0x3319176b32A4c1e68C02Ef454C148eE9b5363C33",
"blockNumber": 5848729,
"cumulativeGasUsed": 89772,
"gasUsed": 89772,
"contractAddress": null,
"logs": [
{
"address": "0x3319176b32A4c1e68C02Ef454C148eE9b5363C33",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009eeab1accb1a701aefab00f3b8a275a39646641c",
"0x0000000000000000000000003e3ff16083bf0a444b8ff86c7156eb3368e3cefb",
"0x000000000000000000000000000000000000000000000000000000000000c29d"
],
"data": "0x",
"blockHash": "0xb71f47ee73a11a8653397bb7e3ea9e40d8bbdc5a2382db72aae854027f5e62c3",
"blockNumber": 5848729,
"transactionHash": "0xd483ec3f28326c27d824b2d42fc434ee16c2f25a900d87c4a6a3dd383e87547d",
"transactionIndex": 0,
"logIndex": 0,
"transactionLogIndex": "0x0",
"removed": false
}
],
"logsBloom": "0x0000000000000000000000000000000000800000...",
"status": 1,
"effectiveGasPrice": 102000000000,
"type": 2
}
}

