Skip to content

feat(transactions): add validateContractName and validateContractId f… - #1831

Open
Wutche wants to merge 1 commit into
stx-labs:mainfrom
Wutche:feat/1804-validate-contract-address
Open

feat(transactions): add validateContractName and validateContractId f…#1831
Wutche wants to merge 1 commit into
stx-labs:mainfrom
Wutche:feat/1804-validate-contract-address

Conversation

@Wutche

@Wutche Wutche commented Jan 4, 2026

Copy link
Copy Markdown

…unctions

Adds validation functions for Stacks contract identifiers. Closes #1804
@janniks

Description

Added two new validation functions for Stacks contract identifiers:

  • validateContractName(name) - Validates contract name according to Clarity rules
  • validateContractId(contractId) - Validates full contract identifier (address.name)

These functions leverage the existing isClarityName() and validateStacksAddress() for consistent validation.

Breaking change?

None - this adds new exports without modifying existing behavior.

Example

import { validateContractName, validateContractId } from '@stacks/transactions';

validateContractName('my-contract');  // true
validateContractName('123invalid');   // false

validateContractId('SP000000000000000000002Q6VF78.pox');  // true
validateContractId('SP000000000000000000002Q6VF78');      // false (no contract name)

Checklist

…unctions

Adds validation functions for Stacks contract identifiers.
Closes stx-labs#1804
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function to validate contract address

2 participants