Skip to content

Add transferStakeFrom and approve functions to staking precompile#2478

Open
jeremyp-tao wants to merge 5 commits intoopentensor:devnet-readyfrom
jeremyp-tao:jeremy-staking-precompile-approvals
Open

Add transferStakeFrom and approve functions to staking precompile#2478
jeremyp-tao wants to merge 5 commits intoopentensor:devnet-readyfrom
jeremyp-tao:jeremy-staking-precompile-approvals

Conversation

@jeremyp-tao
Copy link

Description

Adds new functions to the staking precompile similar to ERC20 transferFrom and approve, which will allow smart contracts to atomically receive alpha tokens and react to the transfer, which is not possible today (if an user transfers alpha token to a smart contract, the latter is not aware of this transfer). Allowance is managed per netuid for finer control.

Related Issue(s)

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

None

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

Not applicable

Additional Notes

None

@open-junius open-junius self-requested a review March 3, 2026 00:39
}

#[precompile::public("increaseAllowance(bytes32,uint256,uint256)")]
fn increase_allowance(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use approve interface to do increase/decrease allowance, and they are not in the standard ERC20 definition.

@open-junius
Copy link
Contributor

It is better to implement both function in an Alpha wrapper contract, instead of in precompile. @ppolewicz @camfairchild any update for ERC20-alpha-wrapper

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.

2 participants