欢迎所有爱好区块链技术的人加入。

ARCHIVES / 524.HTML

js Date 传参给合约 eosio::time_point

Surou EOS-新手教程

合约

void xxx_contract::updatetime(eosio::time_point timestamp){
    require_auth( _self.value );
    system_tables system_table(_self, _self.value);
    auto itr = system_table.begin();
    if(itr == system_table.end()){
        system_table.emplace( _self, [&]( auto& s ) {
            s.id = system_table.available_primary_key();
            s.zero_time = timestamp;
        });
    }else{
        system_table.modify( itr, _self, [&]( auto& s ) {
            s.zero_time = timestamp;
        });
    }
}

Js

push action 参数为 new Date().getTime() * 1000