[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/biz/ - Business & Finance


View post   

File: 320 KB, 1000x1024, file.png [View same] [iqdb] [saucenao] [google]
55017126 No.55017126 [Reply] [Original]

I created a new contract on the FTM testnet and I would like to test it with you /biz/. I'll keep a record of all the early test users for a reward in the future.

Basically, I get people to interact with the contract and give it 1 testnet FTM. When I get a certain number of people into the contract, I will use the "pickWinner" function which will pick a random wallet that interacted with the contract and it will send him all the FTM in the contract.

This is like a mini-lottery, but instead of you having a 1 in a billion chance to win, you have a 1 in [Number of participants, less than 50?] to win.

All of this, again, is with testnet FTM tokens and you have to interact directly on the FTMscan, so the only thing you can lose is some of your time.

NOTE: I used the FTM testnet because it's much easier to get faucet FTM. I will most likely release the full improved contract in a more popular chain later on.

>> No.55017145

you glow bot, and are incompetent
go back attention whoring in your discord sped

>> No.55017197
File: 31 KB, 429x337, 1675764762342047.jpg [View same] [iqdb] [saucenao] [google]
55017197

>>55017145
Do you really F5 /biz/ all day to rush into all new threads and call the OP a bot? Very sad.

>> No.55017213

Anyway, here is a quick tutorial:
1) FTM's official faucet to get testnet FTM:
https://faucet.fantom.network/
Just write your wallet address there.

2) Add and switch to the FTM testnet network on Metamask or whatever wallet you are using.

3) Interact with the contract directly on FTMscan here:
https://testnet.ftmscan.com/address/0x00ce8e7a2004e9399515f900f5bf678ba2424195#writeContract
Use the "enter" function, and write 1 to participate with 1 testnet FTM. 1 is the min, it should give you an error if you try anything lower than that.

Let me know of any feedback or questions.

>> No.55017396

>>55017213
>questions
why no website and how do you plan to profit from this? from what I read you seem to make nothing

>> No.55017407

>>55017126
>>55017213
How hard is learning Solidity

>> No.55017448

>>55017197
i wonder if it's the bots trying to desensitive us

>>55017407
pretty easy if u can code. the idea of sending to/from addresses are a bit weird with how the callbacks are handled but pretty easy. few weeks to get running

>> No.55017465

>>55017448
>few weeks to get running
Have you found it lucrative or just a neat hobby on the side?

>> No.55017482

>>55017396
>why no website
One of the reasons is for you security. Instead of asking you to connect your wallet to an unknown website I could've made it's better for you to do it directly on FTM's official block explorer
>how do you profit
With this early test version of the contract I would make nothing, you're right. But in the final version I will make it so I get a small % of the total prize whenever a winner is selected. It will be used for operational costs, marketing and all that stuff. Another thing I will change in the final version will be for the contract to automatically pick a winner whenever a set number of players enter, instead of relying on me to do it manually.
>>55017407
It's way easier than learning how to draw, at least for me.

>> No.55017728

>>55017482
sounds about right, I will give it a try when I get home

>> No.55018432

has anyone tried it? I dont want my wallet drained

>> No.55018646

>>55017482
You should use a VRF for better randomness. A hash of block.difficulty, block.timestamp and players.length is not random at all on a PoS chain. Difficulty is a PoW thing and on PoS it's a constant (if it exists at all anymore), timestamp is predetermined, and player amount is obviously trivial to know. Now you could run a bot to call pickWinner only when the hash points to your wallet and scam all users. I guess. t. know very little coding or solidity.

>> No.55018759

>>55018646
I did some reading and apparently (on Ethereum) opcode DIFFICULTY (0x44) is now PREVRANDAO and gives you enough (pseudo)randomness for your project.

>> No.55018819

>>55018646
>>55018759
>A hash of block.difficulty, block.timestamp and players.length is not random at all on a PoS chain
I had no idea about that, I will add that in the next contract version for sure. Thanks a lot anon.
>>55018432
You can even try with a new wallet if you're worried about it.
I see one other person interacted with the contract, thank you whoever you are. I will for sure reward you and anyone else who does it for the trust in a near future.
I'll go to sleep now, I doubt this thread will stay up, but when I wake up I'll press the pickWinner button.

>> No.55018845

>>55018646
seems like you read the contract and understand it enough, did you find anything malicious on it?

>> No.55018874

>>55018819
>I will add that in the next contract version for sure.
block.difficulty is an alias for block.prevrandao now and gives you the randomness you want. You don't even have to change anything if you don't want to. You could rename it to block.prevrandao but I don't know how it works in other chains though, only Ethereum. https://eips.ethereum.org/EIPS/eip-4399
>I see one other person interacted with the contract
Issa me, nice to help :)
>>55018845
As I said I don't understand code or solidity that much so my opinion doesn't have much value, but no, I don't see anything outright malicious in the code.

>> No.55019352

>>55018874
i see

>> No.55020964

huh?

>> No.55021410

>>55017482
>Security
There is literally zero security threats involved in connecting your wallet app to any website until you sign/make a transaction at which point it doesn't matter if you use an official blockchain explorer
>A lottery smart contract
Oh boy why didn't anyone think of it until now

>> No.55021729

>>55021410
>Oh boy why didn't anyone think of it until now
Name one that does it exactly like this tho

>> No.55021994

FTMchud here
I'm too lazy to right now but I'll give it a shot

>> No.55022005

>>55018819
Did you do it yet? I feel like participating

>> No.55022015

>>55022005
Haven't yet so go ahead please, I was hoping for at least 5 people

>> No.55022016

>>55017126
>solidity dev here
sup pajeet which country will you invade next with your shitstained genes?

>> No.55022149

>>55022015
Done

>> No.55022378

>>55022149
Nice, alright I'll click the button and see what happens

>> No.55022430

>>55017126
Hello.
Hope you are doing well. I am a senior web and blockchain developer.
- DEX and Swap functions and Bridge
- DeFi development(token staking, farming, bonding, borrowing and lending )
- NFT Marketplace, NFT staking
- Dapp stack (Web3.js / Ethers.js)
- Front-end (React and Next, MUI, MDB, Vue and Nuxt)
I am looking for some remote job or tasks I can do.
Best regards

>> No.55022489
File: 5 KB, 241x250, 1652928164873s.jpg [View same] [iqdb] [saucenao] [google]
55022489

>>55022378
Well, it worked exactly as expected, transactio hash:
https://testnet.ftmscan.com/tx/0xdd08f54d996249d640ccb1823e0f389a1af7b2e757ef08fe294d83055ea5e0de

It randomly picked a winner, in this case https://testnet.ftmscan.com/address/0x59eff99eb146442c8ff745c20cb9802985729456
and sent him all the testnet FTM the contract had.

>> No.55022604

>>55017213
done what now

>> No.55022805

>>55022489
I used AI to audit the contract and it says its solid
I've got another idea for a contract that might be able to be implemented in this way

>> No.55022978

>>55022604
You got in right after I clicked the button, but you helped me check another thing that had me worried. The contract corretly deletes all previous participants from the array and starts from scratch. Very good. This was a huge success.
>what now
Check your wallet every now and then in a near future.
>>55022805
I'm all ears

>> No.55023004
File: 321 KB, 995x713, file.png [View same] [iqdb] [saucenao] [google]
55023004

>>55022978

>> No.55023211

>>55022805
I should make it so the same wallet can't enter twice, right?

>> No.55023314

>>55017126
Another solidityanon here (junior dev).

Code looks decent, however one thing to consider is that your enter() method doesn't weight the contribution to the pot. Sending 1 ftm or 100ftm gives the same chances of winning. To maximise chance of winning you would send as many transactions with minimumBet, but you'd be paying a lot more gas.

I'd recommend changing the array of players to be a mapping of addresses -> uint, storing the amount a player deposits, and changing the pickWinner method to take into account user deposits.

>> No.55023351

>>55023314
I was thinking of changing it so people can only enter the same number of FTMs and also not allowing the same wallet to enter multiple times to keep it more fair.
Would this be a good idea?

>> No.55023403

>>55023351
Not really, if someone cares enough they will make multiple addresses. If you want each ticket to have the same price, simplest solution would be to make each ticket cost a certain amount, then have a mapping of addresses -> number of tickets and do a weighted random chance.

>> No.55024476

>>55023403
>>55023314
Okay, after thinking about it you guys are right. I made all these changes in the code and more.

>> No.55025717

>>55024476
Make the weight exponentially weaker as it grows though if possible
100 tickets shouldn't mean 99 more percent of a chance

>> No.55026649

>>55017126
>Basically, I get people to interact with the contract and give it 1 testnet FTM. When I get a certain number of people into the contract, I will use the "pickWinner" function which will pick a random wallet that interacted with the contract and it will send him all the FTM in the contract.

How are you generating the random number to choose the wallet?

>> No.55026666

>>55026649


function random() private view returns (uint256) {
return uint256(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players.length)));
}

Anon, this can work since it's dependent on player length, though I'd argue you could manipulate this by writing a script to wait for a block that generates the number that chooses your wallet before you choose "pickWinner".

>> No.55028306

>>55026666
huh?

>> No.55029983

>>55017145
>first response is a glowtard
Always on the best threads

>> No.55030864

ok entered

>> No.55031392

I had a dream last night about a similar but much better idea, and best of all I need to change little to no code. This is gonna be a fun project.

>> No.55033188

>>55028306
Huh? You, the contract owner, can rig the contract in your favor to choose your own wallet.

>> No.55033255

bro Im sorry to burst your bubble but you realize crypto casinos are a thing right? I mean I doubt youd pick up interest outside of this...