Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Api/PolygonApi

Polygon API Reference

// Set your API Keys 👇 here
$sdk = new \Tatum\Sdk();

// MainNet API Call
$sdk->mainnet()->api()->polygon();

// TestNet API Call
$sdk->testnet()->api()->polygon();

Methods

Method Description
callPolygonSmartContractMethod() Invoke a method in a smart contract on Polygon
callPolygonSmartContractMethodCaller() Invoke a method in a smart contract on Polygon
callPolygonSmartContractMethodKMS() Invoke a method in a smart contract on Polygon
callPolygonSmartContractReadMethod() Invoke a method in a smart contract on Polygon
polygonBroadcast() Broadcast signed Polygon transaction
polygonGenerateAddress() Generate Polygon account address from Extended public key
polygonGenerateAddressPrivateKey() Generate Polygon private key
polygonGenerateWallet() Generate Polygon wallet
polygonGetBalance() Get Polygon Account balance
polygonGetBlock() Get Polygon block by hash
polygonGetCurrentBlock() Get current block number
polygonGetTransaction() Get Polygon Transaction
polygonGetTransactionByAddress() Get Polygon transactions by address
polygonGetTransactionCount() Get count of outgoing Polygon transactions
transferPolygonBlockchain() Send MATIC from account to account
transferPolygonBlockchainKMS() Send MATIC from account to account

callPolygonSmartContractMethod()

Example

#️⃣ Execute command in terminal

✨ php -f callPolygonSmartContractMethod.php

Request

POST /v3/polygon/smartcontract

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->callPolygonSmartContractMethod(
    \Tatum\Model\CallPolygonSmartContractMethod $call_polygon_smart_contract_method
): \Tatum\Model\CallSmartContractMethod200Response

Parameters

Name Type Description Notes
$call_polygon_smart_contract_method \Tatum\Model\CallPolygonSmartContractMethod    

Return type

\Tatum\Model\CallSmartContractMethod200Response

Description

Invoke a method in a smart contract on Polygon

Back to top


callPolygonSmartContractMethodCaller()

Example

#️⃣ Execute command in terminal

✨ php -f callPolygonSmartContractMethodCaller.php

Request

POST /v3/polygon/smartcontract

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->callPolygonSmartContractMethodCaller(
    \Tatum\Model\CallPolygonSmartContractMethodCaller $call_polygon_smart_contract_method_caller
): \Tatum\Model\CallSmartContractMethod200Response

Parameters

Name Type Description Notes
$call_polygon_smart_contract_method_caller \Tatum\Model\CallPolygonSmartContractMethodCaller    

Return type

\Tatum\Model\CallSmartContractMethod200Response

Description

Invoke a method in a smart contract on Polygon

Back to top


callPolygonSmartContractMethodKMS()

Example

#️⃣ Execute command in terminal

✨ php -f callPolygonSmartContractMethodKMS.php

Request

POST /v3/polygon/smartcontract

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->callPolygonSmartContractMethodKMS(
    \Tatum\Model\CallPolygonSmartContractMethodKMS $call_polygon_smart_contract_method_kms
): \Tatum\Model\CallSmartContractMethod200Response

Parameters

Name Type Description Notes
$call_polygon_smart_contract_method_kms \Tatum\Model\CallPolygonSmartContractMethodKMS    

Return type

\Tatum\Model\CallSmartContractMethod200Response

Description

Invoke a method in a smart contract on Polygon

Back to top


callPolygonSmartContractReadMethod()

Example

#️⃣ Execute command in terminal

✨ php -f callPolygonSmartContractReadMethod.php

Request

POST /v3/polygon/smartcontract

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->callPolygonSmartContractReadMethod(
    \Tatum\Model\CallPolygonSmartContractReadMethod $call_polygon_smart_contract_read_method
): \Tatum\Model\CallSmartContractMethod200Response

Parameters

Name Type Description Notes
$call_polygon_smart_contract_read_method \Tatum\Model\CallPolygonSmartContractReadMethod    

Return type

\Tatum\Model\CallSmartContractMethod200Response

Description

Invoke a method in a smart contract on Polygon

2 credits per API call

Invoke a method in an existing smart contract on Polygon.

You can call a read-only or write method.

  • For read-only methods, the output of the invoked method is returned.
  • For write methods, the ID of the associated transaction is returned.

Troubleshooting a failed transaction Tatum ensures that this API works against the blockchain (accesses the blockchain, finds the specified smart contract, and executes the specified ABI method with the provided parameters). However, because this API can be run against any smart contract on the blockchain, Tatum cannot in any way guarantee that the method itself will be executed successfully.

If you have issues with invoking the method, refer to the user documentation for this method, or contact the author of the smart contract.

For more information about invoking methods in smart contracts, see this article on our Support Portal.

Signing a transaction When invoking a method in a smart contract, you are charged a fee for the transaction, and you must sign the transaction with the private key of the blockchain address from which the fee will be deducted.

If caller field is present instead of the private key, Tatum will sign the transaction with the managed private key connected to the caller address. This is applicable only for paid mainnet plans and all testnet plans. Keep in mind that the caller address must have enough access right to perform the action in the smart contract method.

Providing the private key in the API is not a secure way of signing transactions, because the private key can be stolen or exposed. Your private keys should never leave your security perimeter. You should use the private keys only for testing a solution you are building on the testnet of a blockchain.

For signing transactions on the mainnet, we strongly recommend that you use the Tatum Key Management System (KMS) and provide the signature ID instead of the private key in the API. Alternatively, you can use the Tatum JavaScript client.

Back to top


polygonBroadcast()

Example

#️⃣ Execute command in terminal

✨ php -f polygonBroadcast.php

Request

POST /v3/polygon/broadcast

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonBroadcast(
    \Tatum\Model\BroadcastKMS $broadcast_kms
): \Tatum\Model\TransactionHash

Parameters

Name Type Description Notes
$broadcast_kms \Tatum\Model\BroadcastKMS    

Return type

\Tatum\Model\TransactionHash

Description

Broadcast signed Polygon transaction

2 credits per API call

Broadcast signed transaction to Polygon blockchain. This method is used internally from Tatum KMS or Tatum client libraries. It is possible to create custom signing mechanism and use this method only for broadcasting data to the blockchain.

Back to top


polygonGenerateAddress()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGenerateAddress.php

Request

GET /v3/polygon/address/{xpub}/{index}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGenerateAddress(
    string $xpub,
    float $index
): \Tatum\Model\GeneratedAddressMatic

Parameters

Name Type Description Notes
$xpub string Extended public key of wallet.  
$index float Derivation index of desired address to be generated.  

Return type

\Tatum\Model\GeneratedAddressMatic

Description

Generate Polygon account address from Extended public key

1 credit per API call

Generate Polygon account deposit address from Extended public key. Deposit address is generated for the specific index - each extended public key can generate up to 2^31 addresses starting from index 0 until 2^31.

Back to top


polygonGenerateAddressPrivateKey()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGenerateAddressPrivateKey.php

Request

POST /v3/polygon/wallet/priv

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGenerateAddressPrivateKey(
    \Tatum\Model\PrivKeyRequest $priv_key_request
): \Tatum\Model\PrivKey

Parameters

Name Type Description Notes
$priv_key_request \Tatum\Model\PrivKeyRequest    

Return type

\Tatum\Model\PrivKey

Description

Generate Polygon private key

1 credit per API call

Generate private key of address from mnemonic for given derivation path index. Private key is generated for the specific index - each mnemonic can generate up to 2^31 private keys starting from index 0 until 2^31.

Back to top


polygonGenerateWallet()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGenerateWallet.php

Request

GET /v3/polygon/wallet

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGenerateWallet(
    [ string $mnemonic ]
): \Tatum\Model\Wallet

Parameters

Name Type Description Notes
$mnemonic string Mnemonic to use for generation of extended public and private keys. [optional]

Return type

\Tatum\Model\Wallet

Description

Generate Polygon wallet

1 credit per API call

Tatum supports BIP44 HD wallets. It is very convenient and secure, since it can generate 2^31 addresses from 1 mnemonic phrase. Mnemonic phrase consists of 24 special words in defined order and can restore access to all generated addresses and private keys. Each address is identified by 3 main values:

  • Private Key - your secret value, which should never be revealed
  • Public Key - public address to be published
  • Derivation index - index of generated address

Tatum follows BIP44 specification and generates for Polygon wallet with derivation path m’/44’/966’/0’/0. More about BIP44 HD wallets can be found here - https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki. Generate BIP44 compatible Polygon wallet.

Back to top


polygonGetBalance()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetBalance.php

Request

GET /v3/polygon/account/balance/{address}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetBalance(
    string $address
): \Tatum\Model\MaticBalance

Parameters

Name Type Description Notes
$address string Account address you want to get balance of  

Return type

\Tatum\Model\MaticBalance

Description

Get Polygon Account balance

1 credit per API call

Get Polygon account balance in MATIC. This method does not prints any balance of the ERC20 or ERC721 tokens on the account.

Back to top


polygonGetBlock()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetBlock.php

Request

GET /v3/polygon/block/{hash}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetBlock(
    string $hash
): \Tatum\Model\EthBlock

Parameters

Name Type Description Notes
$hash string Block hash or block number  

Return type

\Tatum\Model\EthBlock

Description

Get Polygon block by hash

1 credit per API call

Get Polygon block by block hash or block number.

Back to top


polygonGetCurrentBlock()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetCurrentBlock.php

Request

GET /v3/polygon/block/current

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetCurrentBlock(): float

Parameters

This endpoint does not need any parameter.

Return type

float

Description

Get current block number

1 credit per API call

Get Polygon current block number. This is the number of the latest block in the blockchain.

Back to top


polygonGetTransaction()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetTransaction.php

Request

GET /v3/polygon/transaction/{hash}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetTransaction(
    string $hash
): \Tatum\Model\PolygonTx

Parameters

Name Type Description Notes
$hash string Transaction hash  

Return type

\Tatum\Model\PolygonTx

Description

Get Polygon Transaction

2 credits per API call

Get Polygon transaction by transaction hash.

Back to top


polygonGetTransactionByAddress()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetTransactionByAddress.php

Request

GET /v3/polygon/account/transaction/{address}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetTransactionByAddress(
    string $address,
    float $page_size,
    [ float $offset, ]
    [ float $from, ]
    [ float $to, ]
    [ string $sort = 'DESC' ]
): \Tatum\Model\PolygonTx[]

Parameters

Name Type Description Notes
$address string Account address you want to get balance of  
$page_size float Max number of items per page is 50.  
$offset float Offset to obtain next page of the data. [optional]
$from float Transactions from this block onwards will be included. [optional]
$to float Transactions up to this block will be included. [optional]
$sort string Sorting of the data. ASC - oldest first, DESC - newest first. [optional] [default to 'DESC']

Return type

\Tatum\Model\PolygonTx[]

Description

Get Polygon transactions by address

1 credit per API call

Get Polygon transactions by address. This includes incoming and outgoing transactions for the address.

Back to top


polygonGetTransactionCount()

Example

#️⃣ Execute command in terminal

✨ php -f polygonGetTransactionCount.php

Request

GET /v3/polygon/transaction/count/{address}

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->polygonGetTransactionCount(
    string $address
): float

Parameters

Name Type Description Notes
$address string address  

Return type

float

Description

Get count of outgoing Polygon transactions

1 credit per API call

Get a number of outgoing Polygon transactions for the address. When a transaction is sent, there can be multiple outgoing transactions, which are not yet processed by the blockchain. To distinguish between them, there is a counter called a nonce, which represents the order of the transaction in the list of outgoing transactions.

Back to top


transferPolygonBlockchain()

Example

#️⃣ Execute command in terminal

✨ php -f transferPolygonBlockchain.php

Request

POST /v3/polygon/transaction

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->transferPolygonBlockchain(
    \Tatum\Model\TransferPolygonBlockchain $transfer_polygon_blockchain
): \Tatum\Model\TransactionSigned

Parameters

Name Type Description Notes
$transfer_polygon_blockchain \Tatum\Model\TransferPolygonBlockchain    

Return type

\Tatum\Model\TransactionSigned

Description

Send MATIC from account to account

2 credits per API call

Send MATIC from account to account.

Signing a transaction

When sending MATIC, you are charged a fee for the transaction, and you must sign the transaction with the private key of the blockchain address from which the fee will be deducted.

Providing the private key in the API is not a secure way of signing transactions, because the private key can be stolen or exposed. Your private keys should never leave your security perimeter. You should use the private keys only for testing a solution you are building on the testnet of a blockchain.

For signing transactions on the mainnet, we strongly recommend that you use the Tatum Key Management System (KMS) and provide the signature ID instead of the private key in the API. Alternatively, you can use the Tatum JavaScript client.

Back to top


transferPolygonBlockchainKMS()

Example

#️⃣ Execute command in terminal

✨ php -f transferPolygonBlockchainKMS.php

Request

POST /v3/polygon/transaction

Type signature

(new \Tatum\Sdk())->{mainnet/testnet}()->api()->polygon()->transferPolygonBlockchainKMS(
    \Tatum\Model\TransferPolygonBlockchainKMS $transfer_polygon_blockchain_kms
): \Tatum\Model\TransactionSigned

Parameters

Name Type Description Notes
$transfer_polygon_blockchain_kms \Tatum\Model\TransferPolygonBlockchainKMS    

Return type

\Tatum\Model\TransactionSigned

Description

Send MATIC from account to account

Back to top