Documentation
¶
Overview ¶
Package rpc provides direct on-chain helpers for Polygon operations — primarily ERC-20 pUSD transfers from an EOA used by deposit-wallet funding.
Calls go through a configured Polygon RPC endpoint and bypass the Polymarket relayer. Used only by live-mode commands behind the funding gate; no read-only or paper-mode code path depends on it.
This package is internal and not part of the polygolem public SDK.
Index ¶
- func ERC20Allowance(ctx context.Context, tokenAddress, owner, spender, rpcURL string) (*big.Int, error)
- func HasCode(ctx context.Context, address string, rpcURL string) (bool, error)
- func IsApprovedForAll(ctx context.Context, tokenAddress, owner, operator, rpcURL string) (bool, error)
- func SwapPOLForExactPUSD(ctx context.Context, privateKeyHex string, amountPUSDOut, maxPOLIn *big.Int, ...) (string, error)
- func TransferPUSD(ctx context.Context, privateKeyHex, toAddress string, amount *big.Int, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ERC20Allowance ¶ added in v0.1.1
func ERC20Allowance(ctx context.Context, tokenAddress, owner, spender, rpcURL string) (*big.Int, error)
ERC20Allowance calls ERC-20 allowance(owner, spender) on the given token via eth_call and returns the uint256 allowance.
func IsApprovedForAll ¶ added in v0.1.1
func IsApprovedForAll(ctx context.Context, tokenAddress, owner, operator, rpcURL string) (bool, error)
IsApprovedForAll calls ERC-1155 isApprovedForAll(owner, operator) on the given token contract via eth_call. Returns false on RPC error to keep the caller fail-closed; the caller should treat any non-true result as "approval missing — refuse to sign".
func SwapPOLForExactPUSD ¶ added in v0.1.1
func SwapPOLForExactPUSD(ctx context.Context, privateKeyHex string, amountPUSDOut, maxPOLIn *big.Int, rpcURL string) (string, error)
SwapPOLForExactPUSD swaps native POL for `amountPUSDOut` (6-decimal pUSD base units) via Uniswap V3 (WMATIC → USDC.e → pUSD multihop, both legs at 0.05% fee tier). msg.value = maxPOLIn; the router refunds unspent POL via multicall(refundETH). The pUSD lands on the EOA controlling privateKeyHex; transfer to deposit wallet via TransferPUSD separately.
It waits for the transaction receipt and returns an error if the swap reverted, so the caller never treats a failed swap (e.g. slippage exceeded or an illiquid pool) as success while POL is consumed.
func TransferPUSD ¶
func TransferPUSD(ctx context.Context, privateKeyHex, toAddress string, amount *big.Int, rpcURL string) (string, error)
TransferPUSD sends pUSD from the EOA (derived from privateKeyHex) to the deposit wallet address. amount is in base units (e.g. "709708" for 0.709708 pUSD). Returns the transaction hash on success.
Types ¶
This section is empty.