DEV Community

Cover image for Deployed a public sale SmartContract on XinFin.
MahaLakshmi Perumal
MahaLakshmi Perumal

Posted on

1

Deployed a public sale SmartContract on XinFin.

Tried a Vanta Public sale smartcontract on XinFin Network and deployed them sucessfully.
refer the code here

pragma solidity ^0.5.3;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;

}

function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract OwnerHelper
{
address public owner;
modifier onlyOwner
{
require(msg.sender == owner);
_;
}
constructor() public
{
owner = msg.sender;
}
function transferOwnership(address _to) public returns (bool)
{
require(_to != owner);
require(_to != address(0x0));
owner = _to;
}
}
contract PublicSale is OwnerHelper {
using SafeMath for uint;
uint public saleEthCount = 0;
uint constant public minEth = 1 ether;
mapping (address => uint) public userEthCount;
constructor() public
{
owner = msg.sender;
}
function () payable external
{
require(msg.value >= minEth);
saleEthCount = saleEthCount.add(msg.value);
userEthCount[msg.sender] = userEthCount[msg.sender].add(msg.value);
}
function withdraw() public onlyOwner
{
msg.sender.transfer(saleEthCount);
}
}

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay