从技术角度来讲,智能合约被认为是网络服务器,只是这些服务器并不是使用IP地址架设在互联网上,而是架设在区块链上。从而可以在其上面运行特定的合约程序。
但是与网络服务器不同的是,所有人都可以看到智能合约,因为这些智能合约的代码和状态都在区块链上(假设区块链是公开的)。而且,与网络服务器不同的是,智能合约不依赖某个特定的硬件设备,事实上,智能合约的代码由所有参与挖矿的设备来执行。
assert recipient!=self
#param max_eth_sold Maximum ETH purchased as intermediary.
#param deadline Time after which this transaction can no longer be executed.
#param exchange_addr The address of the exchange for the token being purchased.
#return Amount of Tokens(self.token)sold.
public
def tokenToExchangeSwapOutput(tokens_bought:uint256,max_tokens_sold:uint256,max_eth_sold:uint256(wei),deadline:timestamp,exchange_addr:address)->uint256:
return self.tokenToTokenOutput(tokens_bought,max_tokens_sold,max_eth_sold,deadline,msg.sender,msg.sender,exchange_addr)
#notice Convert Tokens(self.token)to Tokens(exchange_addr.token)and transfers
#Tokens(exchange_addr.token)to recipient.
#dev Allows trades through contracts that were not deployed from the same factory.
#dev User specifies maximum input and exact output.
#param tokens_bought Amount of Tokens(token_addr)bought.
#param max_tokens_sold Maximum Tokens(self.token)sold.
#param max_eth_sold Maximum ETH purchased as intermediary.
#param deadline Time after which this transaction can no longer be executed.
#param recipient The address that receives output ETH.
#param token_addr The address of the token being purchased.
#return Amount of Tokens(self.token)sold.
public【更全面的开发源码搭建可V or TG我昵称】
def tokenToExchangeTransferOutput(tokens_bought:uint256,max_tokens_sold:uint256,max_eth_sold:uint256(wei),deadline:timestamp,recipient:address,exchange_addr:address)->uint256:
assert recipient!=self
telegram电报快速咨询点击此通道:https://t.me/ch3nguang
return self.tokenToTokenOutput(tokens_bought,max_tokens_sold,max_eth_sold,deadline,msg.sender,recipient,exchange_addr)
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)