Coder Social home page Coder Social logo

sapphire-hardhat-state-issue's Introduction

Sapphire Hardhat integration state issue demonstration

Description

This example tries to demonstrate a problem with the Sapphire Hardhat integration, where the Hardhat script cannot change the state of an existing smart contract, where by all rules it could.

Replicate the issue

  1. Set enviroment variables for two accounts:
PRIVATE_KEY=your_sapphire_private_key_in_hex
PRIVATE_KEY_TESTER=your_sapphire_private_key_in_hex
  1. Fund some ROSE on test accounts
  2. Run deploy
npx hardhat run scripts/deploy.js --network sapphire
  1. Run test
npx hardhat run scripts/test.js --network sapphire

Wrong Test output

Token address: 0xe01dCBaBe0FFB65b29df36C39FA28822517ceb49
Token deployer was:  0x84373E739d2c50eE55EF8a3AF7238f77804f83bF
Testing the contracts with the account: 0xC88309139e5809f4E736D700bB8Aca31540C67d8
1 - Check if tester account has enough ether
Tester account balance: 1992512000000000000
2 - Check if tester account has at least 100 tokens if he has't, send them from deployer account
Deployer account token balance before transfer: 1000000
Tester account token balance before transfer: 0
Deployer account token balance after transfer: 1000000
Tester account token balance after transfer: 0
ERROR: Tester account token balance not changed!!
3 - Check if tester account can transfer 10 token to deployer account
Tester don't have enough tokens to send. Balance: 0

Expected Test output (focus on balance)

Token address: 0x7cb7E002314d616fEA7F4bfE1FD6A9c117561500
Token deployer was:  0x84373E739d2c50eE55EF8a3AF7238f77804f83bF
Testing the contracts with the account: 0xC88309139e5809f4E736D700bB8Aca31540C67d8
1 - Check if tester account has enough ether
Tester account balance: 11979414400000000000
2 - Check if tester account has at least 100 tokens if he has't, send them from deployer account
Deployer account token balance before transfer: 1000000
Tester account token balance before transfer: 0
before transaction
transaction completed
Deployer account token balance after transfer: 999900
Tester account token balance after transfer: 100
3 - Check if tester account can transfer 10 token to deployer account
Deployer account token balance before transfer: 999900
Tester account token balance before transfer: 100
Deployer account token balance after transfer: 999910
Tester account token balance after transfer: 90

Explanation

"ERROR: Tester account token balance not changed!!" --> Smart Contract state has not changed

Issues resolving

  • Smart Contract State doesn't change has been resolved within this issue
  • Error when calling Smart Contract's method from signer other then deployer has been resolved within this - issue

sapphire-hardhat-state-issue's People

Contributors

formator avatar xmzheng avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.