Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ethereum
Skin Z
Commits
52437255
Commit
52437255
authored
Sep 08, 2021
by
Kegan
Browse files
created example SteamToEtherSafe contract that anonymously links steam and eth wallets.
parent
853214ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
contracts/SteamToEtherSafe.sol
0 → 100644
View file @
52437255
//SPDX-License-Identifier: Unlicense
pragma
solidity
^
0.8
.
0
;
import
"hardhat/console.sol"
;
import
"@openzeppelin/contracts/utils/Context.sol"
;
import
"@openzeppelin/contracts/utils/Address.sol"
;
// this is a way to store steam/eth wallet links without exposing what wallet is linked to what steam account
contract
SteamToEtherSafe
is
Context
{
using
Address
for
address
;
mapping
(
uint256
=>
uint256
)
internal
_links
;
constructor
()
{
console
.
log
(
"Deployed SteamToEtherSafe Contract!"
);
}
//verify a eth wallet is a specific steam user
function
Verify
(
uint256
hashed_steamid
,
address
eth_wallet
)
public
view
returns
(
bool
)
{
uint256
_wallet
=
uint256
(
keccak256
(
abi
.
encodePacked
(
eth_wallet
)));
return
VerifyHashed
(
hashed_steamid
,
_wallet
);
}
function
VerifyHashed
(
uint256
hashed_steamid
,
uint256
hashed_eth_wallet
)
public
view
returns
(
bool
)
{
require
(
hashed_steamid
>
0
,
"invalid steamid hash"
);
return
_links
[
hashed_eth_wallet
]
==
hashed_steamid
;
}
function
DoIHaveAnAccount
()
public
view
returns
(
bool
)
{
return
HasAccount
(
_msgSender
());
}
function
HasAccount
(
address
eth_wallet
)
public
view
returns
(
bool
)
{
uint256
_wallet
=
uint256
(
keccak256
(
abi
.
encodePacked
(
eth_wallet
)));
return
HasAccountHashed
(
_wallet
);
}
function
HasAccountHashed
(
uint256
hashed_eth_wallet
)
public
view
returns
(
bool
)
{
return
_links
[
hashed_eth_wallet
]
!=
0
;
}
// what do we do if someone loses their account? forever broken steamid64 link?
function
LinkAccount
(
uint256
hashed_steamid
)
public
{
uint256
_wallet
=
uint256
(
keccak256
(
abi
.
encodePacked
(
_msgSender
())));
require
(
_links
[
_wallet
]
==
0
,
"Account already linked, must unlink from the source wallet"
);
//prevent hackers/others from taking over an accuont link
_links
[
_wallet
]
=
hashed_steamid
;
}
function
UnlinkAccount
()
public
{
uint256
_wallet
=
uint256
(
keccak256
(
abi
.
encodePacked
(
_msgSender
())));
_links
[
_wallet
]
=
0
;
}
//unsafe (exposes steamid64)
function
LinkAccountUnsafe
(
uint64
steamid64
)
public
{
uint256
hashed_steamid
=
uint256
(
keccak256
(
abi
.
encodePacked
(
steamid64
)));
LinkAccount
(
hashed_steamid
);
}
function
VerifyUnsafe
(
uint64
steamid64
,
address
eth_wallet
)
public
view
returns
(
bool
)
{
uint256
hashed_steamid
=
uint256
(
keccak256
(
abi
.
encodePacked
(
steamid64
)));
return
Verify
(
hashed_steamid
,
eth_wallet
);
}
}
\ No newline at end of file
notes/Skin-Z/3. resources/EVM/Hardhat.md
View file @
52437255
...
@@ -3,7 +3,7 @@ Hardhat is a newer development environment for the EVM. I think it's a significa
...
@@ -3,7 +3,7 @@ Hardhat is a newer development environment for the EVM. I think it's a significa
## Notable functions
## Notable functions
`npx hardhat compile`
-> Compiles our smart contracts
-
`npx hardhat compile`
-> Compiles our smart contracts
`npx hardhat test`
-> Runs our test files
-
`npx hardhat test`
-> Runs our test files
`npx hardhat run .\script.js`
-> Run a JS file w/ hardhat
-
`npx hardhat run .\script.js`
-> Run a JS file w/ hardhat
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment