← 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
        )

        let allowedTransfer = (
            boundedTransaction
            and usdt.transfer != null
            and usdt.transfer.amount > 0
            and usdt.transfer.amount <= 10000 * USDT
        )

        allow "transfer" if (allowedTransfer)

        let allowedAllowance = (
            boundedTransaction
            and usdt.approve != null
            and usdt.approve.amount >= 0
            and usdt.approve.amount <= 1000 * USDT
        )

        allow "bounded-allowance" if (allowedAllowance)

        require 2 of [treasury, security] if (
            allowedTransfer and usdt.transfer != null and usdt.transfer.amount > 1000 * USDT
        )
        require security if (allowedAllowance and 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" {
        let allowedTransfer = (
            transaction.contracts.count() == 1
            and transaction.contracts.all(item -> withinTransferLimit(item))
            and transaction.expiration > transaction.timestamp
            and transaction.expiration - transaction.timestamp <= 60000
        )

        allow if (allowedTransfer)

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