Solidity.

首页

欢迎来到Solidity社区论坛

Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

帖子

38
  • MetaInvestor.
    Mar 29, 2025
    专家问答

    How to generate random Number between 1&2 without VRF?

    So I was making a coinflip game which assigns head- 1 and tails -2 and when user places bet on polygon chain.... smart contract generates a random number between 1 and 2 and if the outcome is same...user gets double - (5 % as fee to the owner of contract) ! from a pool and if outcome is different then user loses all and the lost amount is deposited in the pool - (3% as fee to the owner) (to fund winners)... but any way to make genrate a random number? I have no funds at all so I can't afford chainlink VRF to generate. So is there any other secure way for this? plus I am pritty new to solidity so I made this code with help of chat gpt but I don't it works....can anyone help to make the code better? code- // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract CoinFlip { address public owner; uint256 public contractBalance; event BetPlaced(address indexed player, uint256 amount, bool choice); event BetResult(address indexed player, uint256 amount, bool won); constructor() { owner = msg.sender; } function placeBet(bool choice) external payable { require(msg.value > 0, "Bet amount must be greater than 0"); bool outcome = (block.timestamp % 2 == 0); // Simple pseudo-random outcome if (outcome == choice) { uint256 winAmount = (msg.value * 2 * 95) / 100; require(address(this).balance >= winAmount, "Insufficient contract balance"); payable(msg.sender).transfer(winAmount); emit BetResult(msg.sender, winAmount, true); } else { uint256 lostAmount = (msg.value * 97) / 100; contractBalance += lostAmount; emit BetResult(msg.sender, msg.value, false); } emit BetPlaced(msg.sender, msg.value, choice); } function depositFunds() external payable { require(msg.sender == owner, "Only owner can deposit funds"); contractBalance += msg.value; } function withdrawFunds(uint256 amount) external { require(msg.sender == owner, "Only owner can withdraw funds"); require(amount <= address(this).balance, "Insufficient contract balance"); payable(owner).transfer(amount); contractBalance -= amount; } } `

    • Smart Contract
    • Solidity
    0
    1
  • 0xflavoredBy_God.
    Feb 27, 2025
    讨论

    智能合约审计之旅

    你会给刚开始智能合约审计之旅的人什么建议

    • Smart Contract
    • Solidity
    • Yul
    0
    1
  • Eyitayo Da Dev.
    Feb 24, 2025
    讨论

    大家好,我是新来的. 我希望有人能给我链接来有效地学习 solidity.

    //SDPX 许可证标识符:MIT pragma solidity 0.8.24; 合同《你好世界》 { 字符串公开 Hello World; } //只需要在这里添加一些东西

    • Smart Contract
    • Solidity
    0
    2
  • thegreatfeez.
    Dec 09, 2024
    讨论

    Solidity 初学者

    在上了 cyfrin updraft 的初学者课程之后,我正在尝试建造一些东西,这样我就可以巩固知识了,但好像我什么都不知道. 真的让我难过. 你们会给什么建议

    • Smart Contract
    • Solidity
    2
    3
    最佳答案
  • 0x1e3f...4698.
    Sep 13, 2024
    讨论

    为初学者 Solidity 开发人员寻求自由职业机会”

    我已经学习 Solidity 几个星期了,以前没有 IT 背景. 我是否有机会获得自由职业或用我目前的技能赚钱?

    • Solidity
    • Use cases
    0
    0
  • 0xb5d6...1329.
    Jul 24, 2024
    讨论

    格式化/你好

    我是 Solidity 的新手!我想向这个很棒的社区打个招呼,希望它能让我摆脱困境,希望结识新朋友. 我的编程经验为零,但喜欢加密. 在这些论坛上发布问题时,我应该以某种格式发布问题,和/或在这些论坛中我应该遵循什么不太明显的规则? 感谢您抽出时间阅读并留下回复!

    • Smart Contract
    • Solidity
    • Use cases
    0
    1
  • 0xe731...d226.
    Jul 13, 2024
    讨论

    WEB3 审计的职业道路:首先是项目建设还是学习审计?

    大家好, 我最近用 Cyfrin Updraft 完成了 Solidity 和 Foundry 的基础和高级课程. 我正在考虑下一步行动,并考虑在 Solidity 工作. 我应该在这个阶段开始学习智能合约审计,还是先创建一些项目来巩固我目前的知识会更有益? 期待你的建议!

    • Smart Contract
    • Solidity
    0
    1
  • 0xa0c8...4ff4.
    Jun 04, 2024
    专家问答

    solidity 语法多久更改一次

    我想知道 solidity 语法规则多久更改一次,以及跟进最新更新的最佳时事通讯

    • Smart Contract
    • Solidity
    • Language Grammar
    • Solidity Compiler
    1
    1
  • Serpent0x.
    May 31, 2024
    讨论

    重入漏洞

    大家好,我注意到优惠函数使用.call {value: amount} (“”) 方法将以太币发送到收件人的地址. 谁能深入了解该功能是否确实容易受到重入的影响,并提出任何最佳做法或修改以降低此类风险吗? function _offer(address to, uint256 amount) internal { balance -= amount; (bool success, ) = to.call{value: amount}(""); if (!success) { revert TransferFailed(address(0), address(this), to, amount); } } `

    • Smart Contract
    • Solidity
    • Solidity Compiler
    0
    1
  • 0x30b1...765c.
    Apr 04, 2024
    讨论

    关于闪电贷款

    大家好, 我有一个问题,如果用户从贷款池中借了1000美元,而用户做了一些事情怎么办? 现在,如果用户将这笔钱转到另一个地址并销毁了他的钱包怎么办? 因为用户已经转入了另一份合约,那么现在他将如何用1000美元恢复到贷款池中?

    • Solidity
    0
    1

Solidity is an object-oriented, high-level language for implementing smart contracts. It is a curly-bracket language designed to target the Ethereum Virtual Machine (EVM).

38帖子47答案
热门标签
  • Solidity
  • Smart Contract
  • Solidity Compiler
  • Use cases
  • Yul
  • Optimizer
  • Language Grammar
  • Internals
  • Private
我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息