ChainstackProvider from ether.js
to interact with those chains.
ChainstackProvider from ether.js on
the{" "}
Chainstack documentation
.
{error}
} {balances && (Ethereum:{" "} {parseFloat(balances.ethereum).toFixed(5)} ETH
Polygon:{" "} {parseFloat(balances.polygon).toFixed(5)} MATIC
BNB Smart Chain:{" "} {parseFloat(balances.bnb).toFixed(5)} BNB
Arbitrum:{" "} {parseFloat(balances.arbitrum).toFixed(5)} ETH
ChainstackProvider from ether.js
to interact with those chains.
ChainstackProvider from ether.js on
the{" "}
Chainstack documentation
.
{error}
} {balances && (Ethereum:{" "} {parseFloat(balances.ethereum).toFixed(5)} ETH
Polygon:{" "} {parseFloat(balances.polygon).toFixed(5)} MATIC
BNB Smart Chain:{" "} {parseFloat(balances.bnb).toFixed(5)} BNB
Arbitrum:{" "} {parseFloat(balances.arbitrum).toFixed(5)} ETH
Instruction: plan, plan_bump = plan_pda(merchant, plan_id) sub, _ = subscription_pda(plan, subscriber) sa, _ = subscription_authority_pda(subscriber, mint) # The subscriber consents to the exact live plan terms. Read them from chain # so a stale signed transaction can't bind the user to different terms. amount, period_hours, created_at = read_plan_terms(plan) init_id = read_sa_init_id(sa) # SubscribeData (73 bytes): plan_id u64, plan_bump u8, expected_mint, # expected_amount u64, expected_period_hours u64, expected_created_at i64, # expected_sa_init_id i64. data = bytearray([SUBSCRIBE]) data += struct.pack("Instruction: plan, _ = plan_pda(merchant, plan_id) sub, _ = subscription_pda(plan, subscriber) sa, _ = subscription_authority_pda(subscriber, mint) # TransferData (72 bytes): amount u64, delegator (the subscriber), mint. data = bytearray([TRANSFER_SUBSCRIPTION]) data += struct.pack(" int: # SubscriptionAuthority: disc(1) user(32) mint(32) payer(32) bump(1) init_id(i64). data = client.get_account_info(sa).value.data return int.from_bytes(data[98:106], "little", signed=True) def read_plan_terms(plan: Pubkey) -> tuple[int, int, int]: # Plan: disc(1) owner(32) bump(1) status(1) then PlanData at offset 35. # PlanData: plan_id(35:43) mint(43:75) amount(75:83) period_hours(83:91) # created_at(91:99) ... data = client.get_account_info(plan).value.data amount = int.from_bytes(data[75:83], "little") period_hours = int.from_bytes(data[83:91], "little") created_at = int.from_bytes(data[91:99], "little", signed=True) return amount, period_hours, created_at ```