Upgrading SNIP-20 Tokens

I am happy to announce that we are getting close to starting the process of upgrading the SNIP-20 token contracts on Secret Network.

Over the past several months, @supdoggie and @darwinzero were doing a tremendous amount of work to implement the updated SNIP token standard with crucial improvements in privacy and scalability, as well as to develop migration routines that will allow upgrading the existing contracts. This work is supported through SCRT Labs Grants Program.

Main improvements:

  1. Improved privacy with Delayed Write Buffers and Bitwise Trie of Bucketed Entries, addressing the “spicy printf” leaks once and for all. See the detailed description of the solution here.
  2. Improved scalability and UX through Private Notifications - see the description here.
  3. Blanket Permit feature (one permit allowing querying all tokens) - description here.

What this means for users:

  • Stronger privacy: DWBs and BTBEs protect your privacy by removing patterns that could link senders and recipients. This effectively creates large anonymity sets for each transaction — all with low gas costs and no changes to how you send or receive tokens.

  • Instant updates: If you’re using a compatible wallet or dApp, you’ll get instant notifications when you are the recipient of a SNIP transfer. No need to manually check or query the network — it’s a much smoother user experience!

  • Simpler permissions: With blanket permits, you only need to approve one query permit to access all your current and future SNIP tokens. No need to approve each one individually.

The full PR can be seen here.

Testing prior to the upgrade

As part of the process, supdoggie and darwinzero developed an elaborate testing suite to make sure that both the migration and the new implementation work fine.

To test the migration process, the suite creates several synthetic tokens, distributes them across multiple wallets, performs the migration process, and then validates that all the balances are accurate.

In addition, the testing routine performs hundreds of token transfers, covers all possible SNIP-2x actions, and monitors the state of the delayed write buffer and the bitwise trie of bucketed entries while doing so.

In the past weeks, SCRT Labs team ran extensive testing of the upgrade process to validate that everything works as expected. The testing was performed on three levels:

  1. Localsecret
  2. Pulsar-3 testnet
  3. Secret-4 mainnet (using synthetic tokens)

The source code of the testing suite can be found here.

Upgrade Process

The contract migration will be performed in stages:

  1. Stage 1: All SNIP-25 contracts tokens with code-id 877 and 6 decimals
  2. Stage 2: All SNIP-25 contracts with code-id 877 and 8-18 decimals
  3. Stage 3: All SNIP-24 contracts with code-id 563
  4. Stage 4: SNIP-20 contract sSCRT

In each batch, we will start with upgrading less popular tokens (by number of unique wallets accessing them).

The list of all tokens that will be upgraded, and the planned order of upgrade is available here.

Most of the tokens to be upgraded are administered by SCRT Labs, with the exception of two: SILK and SHD that are administered by Shade. We will work closely with the Shade team to help perform the upgrade.

Next Steps

After an initial discussion on the forum, we will post an on-chain signaling proposal to get the network’s formal approval for the upgrade.

6 Likes

I have tokens all with the same hash as shd and silk, snip 25 standard.
hash: "638a3e1d50175fbcb8373cf801565283e3eb23d88a9b7b7f99fcc5eb1e6b561e",
could I get some upgrade instructions when you are stable with your essential snip upgrades?

:globe_showing_americas:

6 decimals btw

1 Like

Sure! Please remind me about this when we start the upgrade.

1 Like

The SNIP-250 migration contracts have been uploaded to mainnet and are ready for upgrades. This post covers the details for the planned migrations. Refer here for the upgrade plan.

If you are interested in deploying a new SNIP 250 token, check out the deployment instructions here.

These upgrades only apply to code IDs 5, 563, and 877. If you are the admin of SNIP token and wish to migrate, make sure your contract matches one of these code IDs and is 6 decimals. If it has 8-18 decimals, the only supported code ID is 877.

You can check which code ID your contract is using with this query:

secretcli query compute contract $CONTRACT_ADDR | jq

To verify the number of decimals:

secretd query compute query $CONTRACT_ADDR '{"token_info":{}}' | jq

To run a migration, fill out the variables below and run the snippet:

export ACCOUNT="YourAccountName"
export NEW_CODE_ID=""  # 2280, 2281, 2282, or 2283
export CONTRACT_ADDR="secret1..."  # existing SNIP contract address

secretcli tx compute migrate $CONTRACT_ADDR $NEW_CODE_ID '{"refund_transfers_to_contract":true}' --from $ACCOUNT

Open-Source Verification

You can verify the migration details listed below with:

export CODE_ID=""  # 2280, 2281, 2282, or 2283
secretcli query compute list-code | jq -r '.code_infos[] | select(.code_id == "'"$CODE_ID"'")'

To verify that the source code from each branch at (prod/sscrt-migrate, prod/snip24-563-6dec-migrate, prod/snip25-877-6dec-migrate, and prod/snip25-877-8-18dec-migrate) compiles to the above code hashes:

  1. Start by checking out the repository
export BRANCH_NAME=""  # prod/sscrt-migrate, prod/snip24-563-6dec-migrate, prod/snip25-877-8-18dec-migrate, or prod/snip25-877-6dec-migrate
git clone --branch BRANCH_NAME --single-branch https://github.com/SolarRepublic/snip20-reference-impl snip250
cd snip250
  1. Compile the contract
make compile-optimized-reproducible
  1. Compute the code hash:
gunzip -c optimized-wasm/snip20_reference_impl.wasm.gz | sha256sum
  1. Compare the resulting code hash to the one reported by your previous list-code query.

Migration details

Batch 1 (SNIP-25 tokens, 6 decimals)

Legacy code ID 877, with 6 decimals only

Contracts:

  • SILK (secret1fl449muk5yq8dlad7a22nje4p5d2pnsgymhjfd)
  • sAXL (secret1vcau4rkn7mvfwl8hf0dqa9p0jr59983e3qqe3z)
  • saUSDC (secret1vkq022x4q8t8kx9de3r84u669l65xnwf2lg3e6)
  • saUSDT (secret1wk5j2cntwg2fgklf0uta3tlkvt87alfj7kepuw)
  • sTIA (secret1s9h6mrp4k9gll4zfv5h78ll68hdq8ml7jrnn20)
  • sANDR (secret1dks96n3jz64dyulzjnjazt6cqemr0x0qgn7sd7)
  • sNSTK (secret16l5g98d45gqvvn2g79q23h8flfq65cvr9r6c72)
  • sLVN (secret1swrj0fqza3g98d7agm2nmukjfe44h7f5n8aavp)
  • sMILKTIA (secret1h08ru5kul3yajg7tqj6vq9k6rccnfw2yqy8glc)
  • sWHALE (secret1pcftk3ny87zm6thuxyfrtrlm2t8yev5unuvx6c)
  • sORAI (secret1sv0nxz6athw5qm0hsxl90376c9zhrxhhprhjph)
  • sstTIA (secret1l5d0vncwnlln0tz0m4tp9rgm740xl7th6es0q0)
  • sUMEE (secret1f6yg0typy608r567xekwyn3qf0k902llue9w2l)
  • sNTRN (secret1k644rvd979wn4erjd5g42uehayjwrq094g5uvj)
  • sECLIP (secret1r4cldegd4peufgtaxf0qpagclqspeqaf8dm0l9)
  • sLNS (secret1yafpcu9wpauy5ktymggzk9kmsvmce0hkl9p2h7)
  • sSAGA (secret19gmvklys9uywk3lf2e94wqwwc97r3jr5rwa2pa)
  • sKAVA (secret1xyhphws090fqs33sxkytmagwynz54eqnpdqfrw)
  • sUSDT (secret1htd6s29m2j9h45knwkyucz98m306n32hx8dww3)
  • sampKUJI (secret1pf6n6j8xlkxnga5t8w8exdtvcrrjgqms5wdlnj)
  • sampWHALE (secret1jsaftfxnwwmjxccvc3zqaqmkcpp8fjnvvltvq6)
  • sbKUJI (secret1ve536yukullq5rm67gdpssm23wynfv9gcqh6xn)
  • sbLUNA (secret1wzqxaa6g6xa27vrwgygex8xurxdjzjtwzlgwy3)
  • sdATOM (secret1x3cxgrwymk7yyelf2782r8ay020xyl96zq3rhh)

Migration details:

Code ID: 2282
Code hash: 72e7242ceb5e3e441243f5490fab2374df0d3e828ce33aa0f0b4aad226cfedd7
Source: https://github.com/SolarRepublic/snip20-reference-impl/tree/f84189ddfd7fbe38bf7c503bb5b817cf1d4c3c18
Branch: prod/snip25-877-6dec-migrate

Batch 2 (SNIP-25 tokens, 8-18 decimals)

Legacy code ID 877, with 8-18 decimals

Contracts:

  • SHD (secret153wu605vvp934xhd4k9dtd640zsep5jkesstdm)
  • saDAI (secret1c2prkwd8e6ratk42l4vrnwz34knfju6hmp7mg7)
  • saWETH (secret139qfh3nmuzfgwsx2npnmnjl4hrvj3xq5rmq8a0)
  • saWBTC (secret1guyayjwg5f84daaxl7w84skd8naxvq8vz9upqx)
  • saFRAX (secret16e230j6qm5u5q30pcc6qv726ae30ak6lzq0zvf)
  • saUNI (secret1egqlkasa6xe6efmfp9562sfj07lq44z7jngu5k)
  • saWBNB (secret19xsac2kstky8nhgvvz257uszt44g0cu6ycd5e4)
  • sARCH (secret188z7hncvphw4us4h6uy6vlq4qf20jd2vm2vu8c)
  • sPAGE (secret1hhvfxy44e4gp6k7n4e37t7uyqa54dnp68egugg)
  • sDYM (secret1vfe63g7ndhqq9qu8v4n97fj69rcmr5fy0dun75)
  • sCHEQ (secret1lfqlcnpveh6at723h5k2nu4jjqeuz0ukpxxdtt)
  • sstDYDX (secret16dctnuy6lwydw834f4d0t3sw3f6jhav6ryhe4m)
  • sWBTC (secret1v2kgmfwgd2an0l5ddralajg5wfdkemxl2vg4jp)
  • sSWTH (secret1mcd6ny9a037g0qf79mkks2tsm0kecw4pll22v7)
  • wstETH (secret1xx6m5c7d92h75evkmxqqe2xe5sk5qcqqs9t8ar)
  • sbINJ (secret17xw4pelwmmhftscrdfntudyv77rkdxvaaelzvs)

Migration details:

Code ID: 2283
Code hash: 967c5878c9aee317fe6b0a7151112cac091d9281b344186c77549db55abb2a8b
Source: https://github.com/SolarRepublic/snip20-reference-impl/tree/f9f17af11ed120a7c6ca55942fbaa4d56262c99a
Branch: prod/snip25-877-8-18dec-migrate

Batch 3 (SNIP-24, 6 decimals)

Legacy code ID 563 (6 decimals)

Contracts: sNOBLEUSD (secret1chsejpk9kfj4vt9ec6xvyguw539gsdtr775us2)

Migration details:

Code ID: 2281
Code hash: b62f055fade3b76654417483136751c7779e90c9f891701cefd37abd4858f41a
Source: https://github.com/SolarRepublic/snip20-reference-impl/tree/22e4d25c2e88d12e80a5dfe9893ae8d00eef60ff
Branch: prod/snip24-563-6dec-migrate

Batch 4 (sSCRT)

Legacy code ID 5 (6 decimals)

Contracts: sSCRT (secret1k0jntykt7e4g3y88ltc60czgjuqdy4c9e8fzek)

Migration details:

Code ID: 2280
Code hash: c8ac20dce1aaf573a27bba8a765b4cd8d3be8d7ed921210b80a0f9563b9315b2
Source: https://github.com/SolarRepublic/snip20-reference-impl/tree/785c078c189095f6313fbd3aa2596b67ba467cc1
Branch: prod/sscrt-migrate
6 Likes

I have verified that the code hashes of the snip250 migration contracts uploaded to the chain can be reproduced from source. Very nice and thorough work, guys :partying_face:

2 Likes

it looks like i didn’t set a contract admin for 2 Snip25 contracts, can I get a hardcoded admin value next network upgrade, please?

Possible, sure. Please send me and Bohdan all the relevant info.

1 Like

The SNIP upgrade train is going full steam:
Today, we successfully upgraded the first five tokens in the list (the ones with the least number of holders and transactions).

All the functionality was tested post-upgrade and found to work fine: transfers, IBC wrap/unwrap, Shade Swaps, Blanket Permit and Private Notifications.

Token Contract address Upgrade Transaction
SBKUJI secret1ve536yukullq5rm67gdpssm23wynfv9gcqh6xn tx
SNLS secret1yafpcu9wpauy5ktymggzk9kmsvmce0hkl9p2h7 tx
SBLUNA secret1wzqxaa6g6xa27vrwgygex8xurxdjzjtwzlgwy3 tx
SNSTK secret16l5g98d45gqvvn2g79q23h8flfq65cvr9r6c72 tx
SDATOM secret1x3cxgrwymk7yyelf2782r8ay020xyl96zq3rhh tx

Tomorrow, we plan to upgrade the next ten tokens:

  • SMILKTIA
  • SKAVA
  • sECLIP
  • SAMPWHALE
  • SUMEE
  • SAMPKUJI
  • SORAI
  • SNTRN
  • SWHALE
  • SUSDT

3 Likes

Additional 10 tokens were upgraded today, including native USDT.

Please see the list below:

Token Contract address Upgrade Transaction
SMILKTIA secret1h08ru5kul3yajg7tqj6vq9k6rccnfw2yqy8glc tx
SKAVA secret1xyhphws090fqs33sxkytmagwynz54eqnpdqfrw tx
sECLIP secret1r4cldegd4peufgtaxf0qpagclqspeqaf8dm0l9 tx
SAMPWHALE secret1jsaftfxnwwmjxccvc3zqaqmkcpp8fjnvvltvq6 tx
SUMEE secret1f6yg0typy608r567xekwyn3qf0k902llue9w2l tx
SAMPKUJI secret1pf6n6j8xlkxnga5t8w8exdtvcrrjgqms5wdlnj tx
SORAI secret1sv0nxz6athw5qm0hsxl90376c9zhrxhhprhjph tx
SNTRN secret1k644rvd979wn4erjd5g42uehayjwrq094g5uvj tx
SWHALE secret1pcftk3ny87zm6thuxyfrtrlm2t8yev5unuvx6c tx
SUSDT secret1htd6s29m2j9h45knwkyucz98m306n32hx8dww3 tx

We will continue the upgrade on Monday or Tuesday next week.

2 Likes

Update on SNIP token upgrade progress

Today, we have upgraded additional SNIP-20 tokens to the new SNIP-250 standard.

See the list of upgrade tokens below:

SPAGE secret1hhvfxy44e4gp6k7n4e37t7uyqa54dnp68egugg tx
SBINJ secret17xw4pelwmmhftscrdfntudyv77rkdxvaaelzvs tx
SSTKDYDX secret16dctnuy6lwydw834f4d0t3sw3f6jhav6ryhe4m tx
SSWTH secret1mcd6ny9a037g0qf79mkks2tsm0kecw4pll22v7 tx
saUNI secret1egqlkasa6xe6efmfp9562sfj07lq44z7jngu5k tx

Tests were passed successfully

We will continue upgrading additional tokens tomorrow:

  • saFRAX
  • SWSTETH
  • saDAI
  • SARCH
  • SDYM
  • SWBTC
  • saWBNB
  • saWBTC
  • saWETH
  • SKSM
  • SDOT
  • SMNTA
  • SDYDX
  • SPICA

Full list of tokens to be upgraded can be found here:

Today, additional 10 tokens were upgraded, including saWBTC(also known as WBTC.axl) and saWETH (also referred to as just WETH).

The upgrade went smoothly, all tests passed.

Here’s the full list of tokens that were upgraded, with the respective upgrade transactions.

Token Upgrade Transaction
saFRAX upgrade tx
SWSTETH upgrade tx
saDAI upgrade tx
SARCH upgrade tx
SDYM upgrade tx
SWBTC upgrade tx
saWBNB upgrade tx
saWBTC upgrade tx
saWETH upgrade tx
SMNTA upgrade tx

I want to thank the Shade team for testing the swap and vault contracts.

The following four tokens with codeid 563 will not actually be upgraded - the upgrade procedure for that codeId only supports tokens with 6 decimals.

  • SKSM (12 decimals)
  • SDOT (10 decimals)
  • SDYDX (18 decimals)
  • SPICA (12 decimals)

Those four tokens were included in the initial upgrade list by mistake.

All remaining tokens have been upgraded, including SSCRT :tada:

3 Likes