In an example contract... where do I have to put the amount of supply that I want, that is, what do I modify to define the total amount for my token? Which word do I change, the one that says "total" or the one that says "totalSupply_"?

Aug 7, 2021, 3:00 PM
constructor(uint256 total) public {
totalSupply_ = total;
balances[msg.sender] = totalSupply_;
}

function totalSupply() public override view returns (uint256) {
return totalSupply_;
}
¿?
constructor(uint256 total) public {
totalSupply_ = 21000000;
balances[msg.sender] = totalSupply_;
}

function totalSupply() public override view returns (uint256) {
return totalSupply_;
}
or
constructor(uint256 total) public {
21000000 = total;
balances[msg.sender] = 21000000;
}

function totalSupply() public override view returns (uint256) {
return 21000000;
}
Thanks in advance
Aug 7, 2021, 3:03 PM
no
_mint(address, amount)
on openzeppelin contract
and instead of using the contract directly
inherit from it
contract yourToken is openzeppelineERC20 {
constructor() ERC20("Name", "SYMBOL") {
_mint(_msgSender(), initialsupply);
}
}
also
21000000 = total;
doesn't make sense
Aug 7, 2021, 3:13 PM
Lol
Aug 7, 2021, 3:13 PM
je
Aug 7, 2021, 3:13 PM
both of them are cursed
sorry lol
Aug 7, 2021, 3:14 PM
ok
Aug 7, 2021, 3:14 PM
that is how you should do it
and change initialsupply with your initial supply
Aug 7, 2021, 3:15 PM
So I have to put this if I don't have an inherited openzeppelin contract?
Aug 7, 2021, 3:15 PM
just make a new contract
and copy and paste that
with an import
import "./ERC20.sol";
Aug 7, 2021, 3:16 PM
Go to the site and play with the wizard
It will help you understand
Aug 7, 2021, 3:16 PM
and pragma solidity ^0.8.0
then your done
pragma solidity ^0.8.0
import "./ERC20.sol";
contract yourToken is ERC20 {
constructor(uint256 initialSupply, string memory name, string memory symbol) ERC20(name, symbol) {
_mint(_msgSender(), initialSupply);
}
}
like that
a new file
Aug 7, 2021, 3:18 PM
https://docs.openzeppelin.com/contracts/4.x/wizard
Aug 7, 2021, 3:21 PM
lol
Aug 7, 2021, 3:22 PM
Someone to enlighten me, I guess they all had a beginning ...
Aug 7, 2021, 3:23 PM
hehe
take 5 minutes
to find out what the problem is
if you still couldn't figure it out
i'll solve it for you
Aug 7, 2021, 3:24 PM
hah line 5
Aug 7, 2021, 3:24 PM
the compiler error is clear
can everyone not tell him lol until after the 5 minutes
Aug 7, 2021, 3:24 PM
Yep read carefully and play with those settings , you will enlighten
Aug 7, 2021, 3:24 PM
Solidity ^0.8.2 🤧
Aug 7, 2021, 3:25 PM
?
read the error :P
Aug 7, 2021, 3:25 PM
Remix is pretty awesome

Does anyone use remixd for localhost ?
Aug 7, 2021, 3:26 PM
it clearly says 'expected' :S
Aug 7, 2021, 3:26 PM
https://github.com/jklepatch/eattheblocks/blob/master/screencast/308-create-bep20-token-bsc/Token.sol
Aug 7, 2021, 3:26 PM
ok 5 minutes have passed
Aug 7, 2021, 3:26 PM
Yay he haven't completed the important statement on line 5 and is missing semicolon
Aug 7, 2021, 3:26 PM
Lo he copiado de aqui
Aug 7, 2021, 3:26 PM
you forgot to add ; at the end of line 5
Aug 7, 2021, 3:26 PM
🤪 line5
Aug 7, 2021, 3:27 PM
thx, uuuu
Sorry I did it with wizard and I wanted to put the safemath on it and left line 5 halfway. How do I put safeMath on it so that the infinite gas loop doesn't happen to me?
Do you see this contract as normal to create a normal and secure token? I wanted to add the ierc20 and the safeMath of openzeppelin to standardize it and give it security. I am very interested in understanding this part.
Aug 7, 2021, 3:33 PM
0.8 doesnt need safemath
openzeppelin has ERC20 code
that is great and secure
Aug 7, 2021, 3:34 PM
great!!
When... this is simple and perfect?
pragma solidity ^0.8.2;

contract Token {
mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
uint public totalSupply = 10000 * 10 ** 18;
string public name = "My Token";
string public symbol = "TKN";
uint public decimals = 18;

event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);

constructor() {
balances[msg.sender] = totalSupply;
}

function balanceOf(address owner) public returns(uint) {
return balances[owner];
}

function transfer(address to, uint value) public returns(bool) {
require(balanceOf(msg.sender) >= value, 'balance too low');
balances[to] += value;
balances[msg.sender] -= value;
emit Transfer(msg.sender, to, value);
return true;
}

function transferFrom(address from, address to, uint value) public returns(bool) {
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}

function approve(address spender, uint value) public returns (bool) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
}
Or would you import some additional opnezeppelin library or something?
Thank you!!
And the gas problem that I have read?
Aug 7, 2021, 3:37 PM
unless you need to
Aug 7, 2021, 4:13 PM
Well I still don't know how I would stop this scenario , my check it at the top
And it still ran 2x

So what's your reason why not use the modifier ?
Or what's the risk ?
Aug 7, 2021, 4:14 PM
bro
its the while loop
most likely
Aug 7, 2021, 4:18 PM
Dood.. I'd that was the case then why are the 2 lines above that loop also running 2x ? Know what I mean ?
Aug 7, 2021, 4:21 PM
give all the code, not just 1 function
as that one function calls other functions
:S
Aug 7, 2021, 4:21 PM
Hmm it's a rabbit hole of code man
Do you wanna go deep on this ? I could allow you read access to the repo

Hell I'd even pay a bug bounty if you find something my dood
🐰
🪲🪲🪲
😆
Aug 7, 2021, 4:24 PM
how much is the bug bounty?
Aug 7, 2021, 4:25 PM
How much do you want ?
Aug 7, 2021, 4:25 PM
how much are you willing to pay?
and will it be problem-based?
Aug 7, 2021, 4:26 PM
Haha
Enough to make it worth your time
Aug 7, 2021, 4:26 PM
0.2 eth?
not sure if thats a lot for you though
Aug 7, 2021, 4:27 PM
Ya like if you find a bug and and prove it and suggest a fix. I would defo pay on that

If the contracts are bug free maybe a base fee for audit
Aug 7, 2021, 4:27 PM
for a critical problem
Aug 7, 2021, 4:28 PM
Why don't we do 0.1 to audit ..and +0.1 for every critical bug ?

And we can define and agree on critical
Aug 7, 2021, 4:30 PM
ok
Aug 7, 2021, 4:30 PM
Ok let me draft some shit up and send a google doc
Just light terms so it's on paper

Cheers
I'll DM you
Aug 7, 2021, 4:31 PM
ok :)
Aug 7, 2021, 4:31 PM
Win win my dood
Aug 7, 2021, 4:32 PM
solidity makes a getter function with public variables
lol
you can just ask it normally
:S
I thought that as well
Aug 7, 2021, 5:10 PM

© 2024 Draquery.com All rights reserved.