SwapFactory Contract Guide: OKTC Documentation

·

Contract Overview

Contract Name: SwapFactory
Contract Address: 0x7b9F0a56cA7D20A44f603C03C6f45Db95b31e539
👉 View Contract on GitHub
👉 Track on OkLink Explorer

Core Functions

Read Functions

getHash()

function getHash() public pure returns(bytes32);

Returns the CreationCode of the SwapPair contract.

getPair(address tokenA, address tokenB)

function getPair(address tokenA, address tokenB) external view returns (address pair);

allPairs(uint index)

function allPairs(uint) external view returns (address pair);

allPairsLength()

function allPairsLength() external view returns (uint);

feeTo() and feeToSetter()

function feeTo() external view returns (address);
function feeToSetter() external view returns (address);

Write Functions

createPair(address tokenA, address tokenB)

function createPair(address tokenA, address tokenB) external returns (address pair);

setFeeTo(address _feeTo) and setFeeToSetter(address _feeToSetter)


Events

PairCreated

event PairCreated(address indexed token0, address indexed token1, address pair, uint);

FAQ Section

1. What happens if I call getPair for non-existent tokens?

The function returns 0x0000000000000000000000000000000000000000.

2. How are tokens ordered in a pair?

Tokens are sorted alphabetically by address (e.g., token0 < token1).

3. Who can change the feeTo address?

Only the feeToSetter address has permission.

4. Can I create multiple pairs for the same tokens?

No, the factory enforces unique pairs per token combination.

5. Where can I verify the contract code?

👉 Check GitHub Repository


Best Practices

This guide adheres to OKTC’s latest standards (2024).