← Digital Assets

TRON signing policies

Set rules for native transactions and declared smart contract calls.

TRON contract calls

Declare TRON contracts and ABI methods. Check decoded arguments, attached TRX or TRC-10 tokens, the fee limit, and expiry.

Integration guide
Edict exampleshowcase-tron.edict
authority "showcase-tron" {
    intent = "tron.transaction"
    version = "1"

    contract usdt: tron {
        address = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"

        fn transfer(to: address, amount: uint256)

        fn approve(spender: address, amount: uint256)
    }

    let USDT = 1000000

    approver treasury {
        type = "reference"
        id = "treasury"
        ref = "treasury@sha256:<digest>"
    }

    approver security {
        type = "reference"
        id = "security"
        ref = "security@sha256:<digest>"
    }

    policy "token-spending" {
        let boundedTransaction = (
            transaction.callValue == 0
            and transaction.callTokenValue == 0
            and transaction.tokenId == 0
            and transaction.feeLimit >= 0
            and transaction.feeLimit <= 30000000
            and transaction.expiration > transaction.timestamp
            and transaction.expiration - transaction.timestamp <= 60000
        )

        allow "transfer" when {
            boundedTransaction
            usdt.transfer != null
            usdt.transfer.amount > 0
            usdt.transfer.amount <= 10000 * USDT
        }

        allow "bounded-allowance" when {
            boundedTransaction
            usdt.approve != null
            usdt.approve.amount >= 0
            usdt.approve.amount <= 1000 * USDT
        }

        require 2 of [treasury, security] if (
            usdt.transfer != null and usdt.transfer.amount > 1000 * USDT
        )
        require security if (usdt.approve != null and usdt.approve.amount > 0)
    }
}

Native TRON transactions

Inspect decoded contracts, including the type, owner, recipient, and amount of a native transfer. Set rules for the permitted actions and when they need approval.

Integration guide
Edict exampleshowcase-trx.edict
authority "showcase-trx" {
    intent = "tron.transaction"
    version = "1"

    let TRX = 1000000

    approver treasury {
        type = "reference"
        id = "treasury"
        ref = "treasury@sha256:<digest>"
    }

    fn withinTransferLimit(item: Contract): Boolean {
        return (item.type == "TransferContract"
            and item.amount != null
            and item.amount > 0
            and item.amount <= 1000 * TRX)
    }

    policy "trx-transfers" {
        allow when {
            transaction.contracts.count() == 1
            transaction.contracts.all(item -> withinTransferLimit(item))
            transaction.expiration > transaction.timestamp
            transaction.expiration - transaction.timestamp <= 60000
        }

        require treasury if (
            transaction.contracts.any(item -> item.amount != null and item.amount > 100 * TRX)
        )
    }
}